switch (type) {
case TYPE_NULL:
- retval = NULL;
break;
case TYPE_NONE:
{
char buf[256], *ptr;
double dx;
- retval = NULL;
n = r_byte(p);
if (n == EOF) {
PyErr_SetString(PyExc_EOFError,
unsigned char *buf;
double x;
buf = (unsigned char *) r_string(8, p);
- if (buf == NULL) {
- retval = NULL;
+ if (buf == NULL)
break;
- }
x = _PyFloat_Unpack8(buf, 1);
- if (x == -1.0 && PyErr_Occurred()) {
- retval = NULL;
+ if (x == -1.0 && PyErr_Occurred())
break;
- }
retval = PyFloat_FromDouble(x);
R_REF(retval);
break;
{
char buf[256], *ptr;
Py_complex c;
- retval = NULL;
n = r_byte(p);
if (n == EOF) {
PyErr_SetString(PyExc_EOFError,
unsigned char *buf;
Py_complex c;
buf = (unsigned char *) r_string(8, p);
- if (buf == NULL) {
- retval = NULL;
+ if (buf == NULL)
break;
- }
c.real = _PyFloat_Unpack8(buf, 1);
- if (c.real == -1.0 && PyErr_Occurred()) {
- retval = NULL;
+ if (c.real == -1.0 && PyErr_Occurred())
break;
- }
buf = (unsigned char *) r_string(8, p);
- if (buf == NULL) {
- retval = NULL;
+ if (buf == NULL)
break;
- }
c.imag = _PyFloat_Unpack8(buf, 1);
- if (c.imag == -1.0 && PyErr_Occurred()) {
- retval = NULL;
+ if (c.imag == -1.0 && PyErr_Occurred())
break;
- }
retval = PyComplex_FromCComplex(c);
R_REF(retval);
break;
{
char *ptr;
n = r_long(p);
- if (PyErr_Occurred()) {
- retval = NULL;
+ if (PyErr_Occurred())
break;
- }
if (n < 0 || n > SIZE32_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (string size out of range)");
- retval = NULL;
break;
}
v = PyBytes_FromStringAndSize((char *)NULL, n);
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
ptr = r_string(n, p);
if (ptr == NULL) {
Py_DECREF(v);
- retval = NULL;
break;
}
memcpy(PyBytes_AS_STRING(v), ptr, n);
is_interned = 1;
case TYPE_ASCII:
n = r_long(p);
- if (PyErr_Occurred()) {
- retval = NULL;
+ if (PyErr_Occurred())
break;
- }
if (n < 0 || n > SIZE32_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (unicode size out of range)");
- retval = NULL;
break;
}
goto _read_ascii;
{
char *ptr;
ptr = r_string(n, p);
- if (ptr == NULL) {
- retval = NULL;
+ if (ptr == NULL)
break;
- }
v = PyUnicode_FromKindAndData(PyUnicode_1BYTE_KIND, ptr, n);
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
if (is_interned)
PyUnicode_InternInPlace(&v);
retval = v;
char *buffer;
n = r_long(p);
- if (PyErr_Occurred()) {
- retval = NULL;
+ if (PyErr_Occurred())
break;
- }
if (n < 0 || n > SIZE32_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (unicode size out of range)");
- retval = NULL;
break;
}
if (n != 0) {
buffer = r_string(n, p);
- if (buffer == NULL) {
- retval = NULL;
+ if (buffer == NULL)
break;
- }
v = PyUnicode_DecodeUTF8(buffer, n, "surrogatepass");
}
else {
v = PyUnicode_New(0, 0);
}
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
if (is_interned)
PyUnicode_InternInPlace(&v);
retval = v;
goto _read_tuple;
case TYPE_TUPLE:
n = r_long(p);
- if (PyErr_Occurred()) {
- retval = NULL;
+ if (PyErr_Occurred())
break;
- }
if (n < 0 || n > SIZE32_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (tuple size out of range)");
- retval = NULL;
break;
}
_read_tuple:
v = PyTuple_New(n);
R_REF(v);
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {
case TYPE_LIST:
n = r_long(p);
- if (PyErr_Occurred()) {
- retval = NULL;
+ if (PyErr_Occurred())
break;
- }
if (n < 0 || n > SIZE32_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (list size out of range)");
- retval = NULL;
break;
}
v = PyList_New(n);
R_REF(v);
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {
case TYPE_DICT:
v = PyDict_New();
R_REF(v);
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
for (;;) {
PyObject *key, *val;
key = r_object(p);
case TYPE_SET:
case TYPE_FROZENSET:
n = r_long(p);
- if (PyErr_Occurred()) {
- retval = NULL;
+ if (PyErr_Occurred())
break;
- }
if (n < 0 || n > SIZE32_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (set size out of range)");
- retval = NULL;
break;
}
v = (type == TYPE_SET) ? PySet_New(NULL) : PyFrozenSet_New(NULL);
if (idx < 0)
Py_CLEAR(v); /* signal error */
}
- if (v == NULL) {
- retval = NULL;
+ if (v == NULL)
break;
- }
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {
PyObject *lnotab = NULL;
idx = r_ref_reserve(flag, p);
- if (idx < 0) {
- retval = NULL;
+ if (idx < 0)
break;
- }
v = NULL;
n = r_long(p);
if (n < 0 || n >= PyList_GET_SIZE(p->refs)) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (invalid reference)");
- retval = NULL;
break;
}
v = PyList_GET_ITEM(p->refs, n);
if (v == Py_None) {
PyErr_SetString(PyExc_ValueError, "bad marshal data (invalid reference)");
- retval = NULL;
break;
}
Py_INCREF(v);
/* Bogus data got written, which isn't ideal.
This will let you keep working and recover. */
PyErr_SetString(PyExc_ValueError, "bad marshal data (unknown type code)");
- retval = NULL;
break;
}