mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-24 11:23:14 -04:00
BUG/MINOR: sink: Return an allocation failure in __sink_new if strdup() fails
This patch fixes GitHub issue #1023.
The function was introduced in commit 99c453d ("MEDIUM: ring: new
section ring to declare custom ring buffers."), which first appeared
in 2.2-dev9. The fix should be backported to 2.2+.
This commit is contained in:
parent
5e8c35da1b
commit
a7ebffef66
1 changed files with 13 additions and 0 deletions
13
src/sink.c
13
src/sink.c
|
|
@ -63,7 +63,13 @@ static struct sink *__sink_new(const char *name, const char *desc, int fmt)
|
|||
goto end;
|
||||
|
||||
sink->name = strdup(name);
|
||||
if (!sink->name)
|
||||
goto err;
|
||||
|
||||
sink->desc = strdup(desc);
|
||||
if (!sink->desc)
|
||||
goto err;
|
||||
|
||||
sink->fmt = fmt;
|
||||
sink->type = SINK_TYPE_NEW;
|
||||
sink->maxlen = BUFSIZE;
|
||||
|
|
@ -74,6 +80,13 @@ static struct sink *__sink_new(const char *name, const char *desc, int fmt)
|
|||
LIST_ADDQ(&sink_list, &sink->sink_list);
|
||||
end:
|
||||
return sink;
|
||||
|
||||
err:
|
||||
free(sink->name); sink->name = NULL;
|
||||
free(sink->desc); sink->desc = NULL;
|
||||
free(sink); sink = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* creates a sink called <name> of type FD associated to fd <fd>, format <fmt>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue