From e67e64ddefb993f7fdea4501f7efbe657cb0f164 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Thu, 10 Jun 2010 12:35:05 -0400 Subject: 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. --- common/ini/ini_config_ut.c | 42 ++++++++++++++++++++++++++++++++++++++++++ common/ini/ini_get_array.c | 2 ++ 2 files changed, 44 insertions(+) diff --git a/common/ini/ini_config_ut.c b/common/ini/ini_config_ut.c index b88b769a..a1ac52ce 100644 --- a/common/ini/ini_config_ut.c +++ b/common/ini/ini_config_ut.c @@ -1205,6 +1205,48 @@ int get_test(void) /***************************************/ + COLOUT(printf("Get empty array item\n")); + + item = NULL; + error = get_config_item("domains/EXAMPLE.COM", + "empty_value", + ini_config, + &item); + if(error) { + printf("Expected success but got error! %d\n", error); + free_ini_config(ini_config); + return error; + } + + /* Item should be found */ + if (item == NULL) { + printf("Expected success but got NULL.\n"); + free_ini_config(ini_config); + return -1; + } + + COLOUT(col_debug_item(item)); + + error = 0; + size = 0; /* Here size is not optional!!! */ + strarray = get_string_config_array(item, ",", &size, &error); + if(error) { + printf("Expect success got error %d.\n", error); + free_ini_config(ini_config); + return error; + } + + if (size != 0) { + for (i=0; i