Skip to content

Commit 483f99a

Browse files
committed
Fix more crash bugs
Now test_marshal fails a few tests instead of segfaulting
1 parent d6d20bf commit 483f99a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/marshal.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ typedef struct {
9090
int version;
9191
} WFILE;
9292

93-
#define count_refs(p) ((p)->hashtable->nentries)
93+
#define count_refs(p) ((p)->hashtable ? (p)->hashtable->nentries : 0)
9494

9595
#define w_byte(c, p) do { \
9696
if ((p)->ptr != (p)->end || w_reserve((p), 1)) \
@@ -1818,14 +1818,14 @@ marshal_load(PyObject *module, PyObject *file)
18181818
rf.readable = file;
18191819
rf.ptr = rf.end = NULL;
18201820
rf.buf = NULL;
1821+
rf.ctx = NULL;
18211822
if ((rf.refs = PyList_New(0)) != NULL) {
18221823
result = read_object(&rf);
18231824
Py_DECREF(rf.refs);
18241825
if (rf.buf != NULL)
18251826
PyMem_Free(rf.buf);
18261827
} else
18271828
result = NULL;
1828-
rf.ctx = NULL;
18291829
}
18301830
Py_DECREF(data);
18311831
return result;

0 commit comments

Comments
 (0)