]> granicus.if.org Git - python/commitdiff
Make sure not to call realloc() with a NULL pointer -- call malloc()
authorGuido van Rossum <guido@python.org>
Mon, 25 Jan 1999 21:43:51 +0000 (21:43 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 25 Jan 1999 21:43:51 +0000 (21:43 +0000)
in that case.  Tamito Kajiyama.

Modules/cPickle.c

index a73a7874f5e7f8fc59f49cc3bd08663591c86535..d259471bc84f2681ce49850ddfd11a1e5743d6a0 100644 (file)
@@ -3275,7 +3275,10 @@ load_mark(Unpicklerobject *self) {
     if ((self->num_marks + 1) >= self->marks_size) {
         s=self->marks_size+20;
         if (s <= self->num_marks) s=self->num_marks + 1;
-        self->marks =(int *)realloc(self->marks, s * sizeof(int));
+        if (self->marks)
+            self->marks=(int *)malloc(s * sizeof(int));
+        else
+            self->marks=(int *)realloc(self->marks, s * sizeof(int));
         if (! self->marks) {
             PyErr_NoMemory();
             return -1;