Fix wrong free 96/246896/2
authorChanggyu Choi <changyu.choi@samsung.com>
Thu, 5 Nov 2020 04:43:14 +0000 (13:43 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Thu, 5 Nov 2020 04:43:37 +0000 (13:43 +0900)
Change-Id: Ib92e807989abc80304dcc3c92258e2b3c999a275
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/stub.cc

index 0c22e5e..416e7e7 100644 (file)
@@ -564,14 +564,14 @@ extern "C" EXPORT_API int bundle_export_to_argv(bundle* b, char*** argv) {
     exported_argv[idx] = strdup(exported_vt[idx].c_str());
     if (exported_argv[idx] == nullptr) {
       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
-      bundle_free_exported_argv(argc, &exported_argv);
+      bundle_free_exported_argv(idx + 1, &exported_argv);
       return -1;
     }
 
     exported_argv[idx + 1] = strdup(exported_vt[idx + 1].c_str());
     if (exported_argv[idx + 1] == nullptr) {
       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
-      bundle_free_exported_argv(argc, &exported_argv);
+      bundle_free_exported_argv(idx + 2, &exported_argv);
       return -1;
     }
   }