瀏覽代碼

Fix memory leak

Some memory could be lost in the error case of
circuit_build_times_parse_state.

Found by Coverity
Sebastian Hahn 16 年之前
父節點
當前提交
7f1f6984da
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 2 0
      ChangeLog
  2. 4 0
      src/or/circuitbuild.c

+ 2 - 0
ChangeLog

@@ -17,6 +17,8 @@ Changes in version 0.2.2.4-alpha - 2009-??-??
   o Minor bugfixes:
   o Minor bugfixes:
     - Fix a couple of smaller issues with gathering statistics. Bugfixes
     - Fix a couple of smaller issues with gathering statistics. Bugfixes
       on 0.2.2.1-alpha.
       on 0.2.2.1-alpha.
+    - Fix two memory leaks in the error case of
+      circuit_build_times_parse_state. Bugfix on 0.2.2.2-alpha.
 
 
 Changes in version 0.2.2.3-alpha - 2009-09-23
 Changes in version 0.2.2.3-alpha - 2009-09-23
   o Major bugfixes:
   o Major bugfixes:

+ 4 - 0
src/or/circuitbuild.c

@@ -427,6 +427,8 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
       if (!ok) {
       if (!ok) {
         *msg = tor_strdup("Unable to parse circuit build times: "
         *msg = tor_strdup("Unable to parse circuit build times: "
                           "Unparsable bin number");
                           "Unparsable bin number");
+        SMARTLIST_FOREACH(args, char*, cp, tor_free(cp));
+        smartlist_free(args);
         break;
         break;
       }
       }
       count = (uint32_t)tor_parse_ulong(count_str, 0, 0,
       count = (uint32_t)tor_parse_ulong(count_str, 0, 0,
@@ -434,6 +436,8 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
       if (!ok) {
       if (!ok) {
         *msg = tor_strdup("Unable to parse circuit build times: "
         *msg = tor_strdup("Unable to parse circuit build times: "
                           "Unparsable bin count");
                           "Unparsable bin count");
+        SMARTLIST_FOREACH(args, char*, cp, tor_free(cp));
+        smartlist_free(args);
         break;
         break;
       }
       }