Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa8d167

Browse files
committed
Make sure not to call realloc() with a NULL pointer -- call malloc()
in that case. Tamito Kajiyama.
1 parent 1180185 commit aa8d167

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/cPickle.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,10 @@ load_mark(Unpicklerobject *self) {
32753275
if ((self->num_marks + 1) >= self->marks_size) {
32763276
s=self->marks_size+20;
32773277
if (s <= self->num_marks) s=self->num_marks + 1;
3278-
self->marks =(int *)realloc(self->marks, s * sizeof(int));
3278+
if (self->marks)
3279+
self->marks=(int *)malloc(s * sizeof(int));
3280+
else
3281+
self->marks=(int *)realloc(self->marks, s * sizeof(int));
32793282
if (! self->marks) {
32803283
PyErr_NoMemory();
32813284
return -1;

0 commit comments

Comments
 (0)