This patch fixes GitHub issue #1023.

The function was introduced in commit 67b5a161b4aa5cf9eb18a609fcbb64ec744ae7ea,
which first appeared in 2.1-dev2. The fix should be backported to 2.1+.
---
 src/sink.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/sink.c b/src/sink.c
index 35bf7707c..15fc47597 100644
--- a/src/sink.c
+++ b/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>,
-- 
2.29.0


Reply via email to