[or-cvs] Force tor_malloc(0) to always be sane

Nick Mathewson nickm at seul.org
Thu Apr 8 03:05:10 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv29516/src/common

Modified Files:
	util.c 
Log Message:
Force tor_malloc(0) to always be sane

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- util.c	7 Apr 2004 21:36:03 -0000	1.84
+++ util.c	8 Apr 2004 03:05:08 -0000	1.85
@@ -69,6 +69,10 @@
 void *tor_malloc(size_t size) {
   void *result;
 
+  /* Some libcs don't do the right thing on size==0. Override them. */
+  if (size==0) {
+    size=1;
+  }
   result = malloc(size);
 
   if(!result) {



More information about the tor-commits mailing list