|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From d9ab174bd7ec1dd5b382d3d84737d1c9ed1f4481 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Andreas Henriksson <andreas@fatal.se>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Tue, 16 Sep 2014 21:36:26 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] shared: fix resource leak in config_parse_default_instance
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
The recently allocated "printed" is not freed on error path.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Found by coverity. Fixes: CID#1237745
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/install.c | 4 +++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/install.c b/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 5d3fcf5e32..61e572bdf3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1025,8 +1025,10 @@ static int config_parse_default_instance(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (!unit_instance_is_valid(printed))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!unit_instance_is_valid(printed)) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ free(printed);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
free(i->default_instance);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
i->default_instance = printed;
|