diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2013-03-20 21:26:33 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <sweskman@gmail.com> | 2013-03-20 21:26:33 (GMT) |
commit | 61683625096676722dc487aa1e9894a5b604e220 (patch) | |
tree | 1b52998a07659e8d46dd4f58d600ae55f9419376 /Python | |
parent | e178187bf639f0af8cc9c2b97d5358918c4b2c9e (diff) | |
download | cpython-61683625096676722dc487aa1e9894a5b604e220.zip cpython-61683625096676722dc487aa1e9894a5b604e220.tar.gz cpython-61683625096676722dc487aa1e9894a5b604e220.tar.bz2 |
Issue #16475 : Correctly handle the EOF when reading marshal streams.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/marshal.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Python/marshal.c b/Python/marshal.c index 4e55296..bd88939 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -808,10 +808,16 @@ r_object(RFILE *p) PyObject *v, *v2; Py_ssize_t idx = 0; long i, n; - int type = r_byte(p); + int type, code = r_byte(p); int flag; PyObject *retval; + if (code == EOF) { + PyErr_SetString(PyExc_EOFError, + "EOF read where object expected"); + return NULL; + } + p->depth++; if (p->depth > MAX_MARSHAL_STACK_DEPTH) { @@ -820,8 +826,8 @@ r_object(RFILE *p) return NULL; } - flag = type & FLAG_REF; - type = type & ~FLAG_REF; + flag = code & FLAG_REF; + type = code & ~FLAG_REF; #define R_REF(O) do{\ if (flag) \ @@ -830,12 +836,6 @@ r_object(RFILE *p) switch (type) { - case EOF: - PyErr_SetString(PyExc_EOFError, - "EOF read where object expected"); - retval = NULL; - break; - case TYPE_NULL: retval = NULL; break; |