fix for resource leak 44/212244/3 accepted/tizen/unified/20190905.232229 submit/tizen/20190828.061756 submit/tizen/20190829.043227 submit/tizen/20190829.094028 submit/tizen/20190830.023608 submit/tizen/20190830.034707 submit/tizen/20190905.064609
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Mon, 19 Aug 2019 08:00:10 +0000 (10:00 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Wed, 21 Aug 2019 10:01:28 +0000 (10:01 +0000)
Fix for leak of memory, where memory allocated by vconf_get_key would
not be freed.

Change-Id: If4e7ba2aaee28c261ebf77e7ac73a72f74ce78b3

src/service/VConf.cpp

index 308a9e0..1994110 100644 (file)
@@ -202,8 +202,11 @@ class VConfImpl : public VConfInterface
        {
                auto k = keyPrefix + key;
                auto vconfStr = vconf_get_str(k.c_str());
-               if (vconfStr)
-                       return std::string{vconfStr};
+               if (vconfStr) {
+                       auto s = std::string{ vconfStr };
+                       free(vconfStr);
+                       return std::move(s);
+               }
 
                WARNING("Vconf: cant get value for key: %s, returning default value = %s", k.c_str(), value.c_str());
                return value;