From 17dec0f703bea85d6cbbae2a75d7960a5f6bb666 Mon Sep 17 00:00:00 2001 From: reverendhomer Date: Wed, 7 Oct 2015 11:55:31 +0300 Subject: [PATCH] service: fix memory leak in service_add_fd_store() fixes Coverity #1325767 --- src/core/service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/service.c b/src/core/service.c index 8c339765a4c..ce3b81398d6 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -363,8 +363,10 @@ static int service_add_fd_store(Service *s, int fd, const char *name) { fs->fd = fd; fs->service = s; fs->fdname = strdup(name ?: "stored"); - if (!fs->fdname) + if (!fs->fdname) { + free(fs); return -ENOMEM; + } r = sd_event_add_io(UNIT(s)->manager->event, &fs->event_source, fd, 0, on_fd_store_io, fs); if (r < 0) {