Commits

Greg Ward committed 8fbe8cf

fossil: fix memory leaks

  • Participants
  • Parent commits aed6925

Comments (0)

Files changed (2)

File src/capture.h

  * capture->stdout.len the number of bytes read. capture->stdout.buf
  * is null terminated, so as long as the child's output is textual,
  * you can use it as a string. Similarly, child's stderr is in
- * capture->stderr.buf and capture->stderr.len.
+ * capture->stderr.buf and capture->stderr.len. Caller is responsible
+ * for freeing the result with free_capture().
  */
 capture_t *
 capture_child(const char *file, char *const argv[]);

File src/fossil.c

                             strstr(cstdout, "\nUPDATED") ||
                             strstr(cstdout, "\nMERGED"));
     }
+
+    cstdout = NULL;
+    free_capture(capture);
+
     if (context->options->show_unknown) {
         // This can't be read from 'fossil status' output
         char *argv[] = {"fossil", "extra", NULL};
             return NULL;
         }
         result->unknown = (capture->stdout.len > 0);
+        free_capture(capture);
     }
 
     return result;