OSDN Git Service

fix some memory leaks.
authorYunlian Jiang <yunlian@google.com>
Wed, 1 Feb 2017 00:17:50 +0000 (16:17 -0800)
committerJoe Onorato <joeo@google.com>
Thu, 20 Apr 2017 17:28:00 +0000 (10:28 -0700)
This fixes some warnings like

warning: Potential leak of memory pointed to by 'target'
[clang-analyzer-cplusplus.NewDeleteLeaks]

Bug: None
Test: The warnings are gone.
Change-Id: I3708671bbc9965133439664b766df3236d1b01bf

tools/incident_report/main.cpp

index 884b8e4..1d8809f 100644 (file)
@@ -355,6 +355,7 @@ adb_incident_workaround(const char* adbSerial, const vector<string>& sections)
             args[argpos++] = NULL;
             execvp(args[0], (char*const*)args);
             fprintf(stderr, "execvp failed: %s\n", strerror(errno));
+            free(args);
             return 1;
         } else {
             // parent
@@ -400,6 +401,7 @@ adb_incident_workaround(const char* adbSerial, const vector<string>& sections)
         }
     }
 
+    free(buffer);
     return 0;
 }