mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-21 22:45:34 +00:00
BUG/MINOR: log: fix memory leak on logsrv parse error
In case of parsing error on logsrv, we can leave parse_logsrv() without releasing logsrv->ring_name or smp_rgs. Let's free them on the error path. This should fix issue #926 detected by Coverity. The impact is only a tiny leak just before reporting a fatal error, so it will essentially annoy valgrind. This can be backported to 2.0 (just drop the ring part).
This commit is contained in:
parent
a73a222a98
commit
ae32ac74db
@ -799,6 +799,7 @@ int smp_log_range_cmp(const void *a, const void *b)
|
|||||||
*/
|
*/
|
||||||
int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
|
int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
|
||||||
{
|
{
|
||||||
|
struct smp_log_range *smp_rgs = NULL;
|
||||||
struct sockaddr_storage *sk;
|
struct sockaddr_storage *sk;
|
||||||
struct logsrv *logsrv = NULL;
|
struct logsrv *logsrv = NULL;
|
||||||
int port1, port2;
|
int port1, port2;
|
||||||
@ -905,7 +906,6 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
|
|||||||
if (strcmp(args[cur_arg], "sample") == 0) {
|
if (strcmp(args[cur_arg], "sample") == 0) {
|
||||||
unsigned low, high;
|
unsigned low, high;
|
||||||
char *p, *beg, *end, *smp_sz_str;
|
char *p, *beg, *end, *smp_sz_str;
|
||||||
struct smp_log_range *smp_rgs = NULL;
|
|
||||||
size_t smp_rgs_sz = 0, smp_sz = 0, new_smp_sz;
|
size_t smp_rgs_sz = 0, smp_sz = 0, new_smp_sz;
|
||||||
|
|
||||||
p = args[cur_arg+1];
|
p = args[cur_arg+1];
|
||||||
@ -1038,6 +1038,8 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
free(smp_rgs);
|
||||||
|
free(logsrv->ring_name);
|
||||||
free(logsrv);
|
free(logsrv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user