remove memory leak and use after free
authorSeungYeup Kim <sy2004.kim@samsung.com>
Tue, 28 Aug 2012 09:18:44 +0000 (18:18 +0900)
committerSeungYeup Kim <sy2004.kim@samsung.com>
Tue, 28 Aug 2012 10:10:26 +0000 (19:10 +0900)
Change-Id: Ic66b3e175aa78e7d11c8492c83d2244c42589084

packaging/vconf.spec
vconf.c

index 67085aacefb6c18bb22dbc457eca8144b21fbebc..4279341cd3a134853c79dff70f2572d0419076da 100755 (executable)
@@ -1,7 +1,7 @@
 Name:       vconf
 Summary:    Configuration system library
-Version:    0.2.26
-Release:    1
+Version:    0.2.27
+Release:    0
 Group:      System/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
@@ -77,6 +77,10 @@ ln -sf /etc/rc.d/init.d/vconf-init %{buildroot}/etc/rc.d/rc4.d/S04vconf-init
 %{_includedir}/vconf/vconf-keys.h
 
 %changelog
+* Tue Aug 28 2012 - SeungYeup Kim <sy2004.kim@samsung.com>
+- Remove memory leak
+- Remove use after free
+
 * Tue Aug 14 2012 - Hyungdeuk Kim <hd3.kim@samsung.com>
 - Fix issues related prevent
 - Fix warning msg at build time
diff --git a/vconf.c b/vconf.c
index 88708d6c69ad1a6c165e764a2ee0c23c1008c0a5..be0e42fc7d90b37638746dce83af8d53b0635001 100755 (executable)
--- a/vconf.c
+++ b/vconf.c
@@ -1472,6 +1472,8 @@ static int _vconf_get_key_filesys(keynode_t *keynode, int prefix)
                                        _vconf_keynode_set_value_str(keynode, "");
                                }
                        }
+                       if(value)
+                               free(value);
 
                        break;
                }
@@ -1693,7 +1695,6 @@ API int vconf_get(keylist_t *keylist, const char *dirpath, get_option_t option)
                }
 
                if((readdir_r(dir, &entry, &result)) != 0) {
-                       closedir(dir);
                        strerror_r(errno, err_buf, ERR_LEN);
                        ERR("ERROR : read directory(%s) fail(%s)", dirpath, err_buf);
                        func_ret = VCONF_ERROR;