summaryrefslogtreecommitdiffstats
path: root/Modules/cPickle.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-25 21:43:51 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-25 21:43:51 (GMT)
commitaa8d16761b6e2dfe9a5c7596f07f96a9cd96dff1 (patch)
tree234561c7f1216c01996a41361a710722f4a2a806 /Modules/cPickle.c
parent11801859e020e414d43780489dd8e31b3f4e0a86 (diff)
downloadcpython-aa8d16761b6e2dfe9a5c7596f07f96a9cd96dff1.zip
cpython-aa8d16761b6e2dfe9a5c7596f07f96a9cd96dff1.tar.gz
cpython-aa8d16761b6e2dfe9a5c7596f07f96a9cd96dff1.tar.bz2
Make sure not to call realloc() with a NULL pointer -- call malloc()
in that case. Tamito Kajiyama.
Diffstat (limited to 'Modules/cPickle.c')
-rw-r--r--Modules/cPickle.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index a73a787..d259471 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;