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

[or-cvs] Fix possible-but-unlikely free(NULL) in control.c [backport].



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv26420/src/or

Modified Files:
      Tag: tor-0_1_0-patches
	control.c 
Log Message:
Fix possible-but-unlikely free(NULL) in control.c [backport].

Index: control.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.83.2.3
retrieving revision 1.83.2.4
diff -u -d -r1.83.2.3 -r1.83.2.4
--- control.c	7 Aug 2005 19:40:17 -0000	1.83.2.3
+++ control.c	2 Nov 2005 17:55:02 -0000	1.83.2.4
@@ -421,12 +421,15 @@
                        (uint16_t)msg_len, msg_len?msg:NULL);
 
  done:
-  if (answers) SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp));
-  if (questions) SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp));
-  smartlist_free(answers);
-  smartlist_free(questions);
+  if (answers) {
+    SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp));
+    smartlist_free(answers);
+  }
+  if (questions) {
+    SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp));
+    smartlist_free(questions);
+  }
   tor_free(msg);
-
   return 0;
 }
 
@@ -695,10 +698,14 @@
                        msg_len, msg);
 
  done:
-  if (answers) SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp));
-  if (questions) SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp));
-  smartlist_free(answers);
-  smartlist_free(questions);
+  if (answers) {
+    SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp));
+    smartlist_free(answers);
+  }
+  if (questions) {
+    SMARTLIST_FOREACH(questions, char *, cp, tor_free(cp));
+    smartlist_free(questions);
+  }
   tor_free(msg);
 
   return 0;