[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master 1/7] Fix a memory leak in circuit_build_times_parse_state



Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date: Sun, 15 Aug 2010 14:22:32 +0200
Subject: Fix a memory leak in circuit_build_times_parse_state
Commit: 70f0ba1495dce3b7c912354e2690fa9588b4e5b5

Thanks weasel for noticing.
---
 changes/bug1831       |    3 +++
 src/or/circuitbuild.c |    6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 changes/bug1831

diff --git a/changes/bug1831 b/changes/bug1831
new file mode 100644
index 0000000..40b3fcf
--- /dev/null
+++ b/changes/bug1831
@@ -0,0 +1,3 @@
+  o Minor bugfixes
+    - Fix a memory leak in the error case of circuit_build_times_parse_state().
+      Bugfix on 0.2.2.14-alpha; fixes bug 1831 partially.
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 5bb9d70..9749a56 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -692,7 +692,8 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
             "Corrupt state file? Build times count mismatch. "
             "Read %d times, but file says %d", loaded_cnt,
             state->TotalBuildTimes);
-    *msg = tor_strdup("Build times count mismatch.");
+    if (!*msg)
+      *msg = tor_strdup("Build times count mismatch.");
     circuit_build_times_reset(cbt);
     tor_free(loaded_times);
     return -1;
@@ -716,7 +717,8 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
             "Corrupt state file? Shuffled build times mismatch. "
             "Read %d times, but file says %d", tot_values,
             state->TotalBuildTimes);
-    *msg = tor_strdup("Build times count mismatch.");
+    if (!*msg)
+      *msg = tor_strdup("Build times count mismatch.");
     circuit_build_times_reset(cbt);
     tor_free(loaded_times);
     return -1;
-- 
1.7.1