summaryrefslogtreecommitdiffstats
path: root/common/ini/ini_get_array.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-06-10 12:35:05 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-06-28 08:38:14 -0400
commite67e64ddefb993f7fdea4501f7efbe657cb0f164 (patch)
tree78f3184b5b90983096146d2f34fda29e1a293f36 /common/ini/ini_get_array.c
parent9d3bd4b906fbfc879cec06d9cdad44db7c15c5ff (diff)
downloadsssd-e67e64ddefb993f7fdea4501f7efbe657cb0f164.tar.gz
sssd-e67e64ddefb993f7fdea4501f7efbe657cb0f164.tar.xz
sssd-e67e64ddefb993f7fdea4501f7efbe657cb0f164.zip
Memory leak in case of empty value
Addressing coverity issue. Ticket #513. The memory was really leaked when the configuration value was empty. Added unit test that confirmed the bug. MANUAL MERGE.
Diffstat (limited to 'common/ini/ini_get_array.c')
-rw-r--r--common/ini/ini_get_array.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/ini/ini_get_array.c b/common/ini/ini_get_array.c
index c2c6362ad..b2cbfacf9 100644
--- a/common/ini/ini_get_array.c
+++ b/common/ini/ini_get_array.c
@@ -162,6 +162,8 @@ static char **get_str_cfg_array(struct collection_item *item,
if (error) *error = EOK;
if (size) *size = count;
+ /* If count is 0 the copy needs to be freed */
+ if (count == 0) free(copy);
TRACE_FLOW_STRING("get_str_cfg_array", "Exit");
return array;
}