From: Guido van Rossum Date: Mon, 25 Jan 1999 21:43:51 +0000 (+0000) Subject: Make sure not to call realloc() with a NULL pointer -- call malloc() X-Git-Tag: v1.5.2b2~280 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa8d16761b6e2dfe9a5c7596f07f96a9cd96dff1;p=thirdparty%2FPython%2Fcpython.git Make sure not to call realloc() with a NULL pointer -- call malloc() in that case. Tamito Kajiyama. --- diff --git a/Modules/cPickle.c b/Modules/cPickle.c index a73a7874f5e7..d259471bc84f 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -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;