cpython: 5fa793ae36cc (original) (raw)

--- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -2,6 +2,7 @@ from test import support import array +import io import marshal import sys import unittest @@ -259,6 +260,17 @@ class BugsTestCase(unittest.TestCase): unicode_string = 'T' self.assertRaises(TypeError, marshal.loads, unicode_string)

+ def _test_eof(self): data = marshal.dumps(("hello", "dolly", None)) for i in range(len(data)):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #17872: Fix a segfault in marshal.load() when input stream returns

--- a/Python/marshal.c +++ b/Python/marshal.c @@ -570,8 +570,17 @@ r_string(char *s, Py_ssize_t n, RFILE *p else { read = (int)PyBytes_GET_SIZE(data); if (read > 0) {

@@ -841,11 +850,13 @@ r_object(RFILE *p) double dx; retval = NULL; n = r_byte(p);

@@ -860,8 +871,6 @@ r_object(RFILE p) unsigned char buf[8]; double x; if (r_string((char)buf, 8, p) != 8) {

@@ -881,21 +890,25 @@ r_object(RFILE *p) Py_complex c; retval = NULL; n = r_byte(p);

@@ -910,8 +923,6 @@ r_object(RFILE p) unsigned char buf[8]; Py_complex c; if (r_string((char)buf, 8, p) != 8) {

@@ -921,8 +932,6 @@ r_object(RFILE p) break; } if (r_string((char)buf, 8, p) != 8) {

@@ -954,8 +963,6 @@ r_object(RFILE *p) } if (r_string(PyBytes_AS_STRING(v), n, p) != n) { Py_DECREF(v);

@@ -986,8 +993,6 @@ r_object(RFILE *p) } if (r_string(buffer, n, p) != n) { PyMem_DEL(buffer);