From 42546acf3fca191f92cb0bebcae6faff0f822bbe Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 6 Aug 2020 15:16:39 +1000 Subject: [PATCH] libei: fix the source ref handling Plugs a memleak in libeis where we don't care about the return value of the source_add_autoclose(). Signed-off-by: Peter Hutterer --- src/libei.c | 3 ++- src/util-sources.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libei.c b/src/libei.c index b685784..8985616 100644 --- a/src/libei.c +++ b/src/libei.c @@ -703,7 +703,8 @@ error: int ei_set_connection(struct ei *ei, int fd) { - ei->source = source_add_autoclose(ei->sink, fd, connection_dispatch, ei); + struct source *source = source_add_autoclose(ei->sink, fd, connection_dispatch, ei); + ei->source = source_ref(source); if (!ei->source) return -ENOMEM; diff --git a/src/util-sources.c b/src/util-sources.c index 707582b..1d799b7 100644 --- a/src/util-sources.c +++ b/src/util-sources.c @@ -118,7 +118,7 @@ source_add(struct sink *sink, int sourcefd, list_append(&sink->sources, &source->link); - return source_ref(source); + return source; } struct source *