Fix a possible memory leak from _ctx_history_query() 30/124630/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 12 Apr 2017 04:16:34 +0000 (13:16 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 12 Apr 2017 04:16:34 +0000 (13:16 +0900)
Change-Id: I46fda7210ab90c515a135ba03196262e2c113d8a
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/client/app_history.cpp

index 19e68df..8e18fd3 100644 (file)
@@ -50,17 +50,17 @@ EXPORT_API int _ctx_history_query(const char* uri, const char* filter, ctx_histo
        g_variant_get(output, "(&sv)", &columnNames, &results);
 
        ctx_history_cursor_s* csr = new(std::nothrow) ctx_history_cursor_s;
-       IF_FAIL_RETURN(csr, E_NO_MEM);
+       if (!csr) {
+               _E_ALLOC;
+               g_variant_unref(results);
+               g_variant_unref(output);
+               return E_NO_MEM;
+       }
 
        std::string names = columnNames;
        csr->index = 0;
        csr->keys = util::tokenizeString(names, ",");
-       try {
-               csr->tuples = Tuple::buildFrom(results);
-       } catch (const std::exception& e) {
-               _E("Exception: %s", e.what());
-               err = E_FAILED;
-       }
+       csr->tuples = Tuple::buildFrom(results);
 
        g_variant_unref(output);
        *cursor = csr;