Skip to content

Commit ed50a4a

Browse files
committed
Fix error handling in pylong_int_from_string().
1 parent 43d61e3 commit ed50a4a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Objects/longobject.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -2358,24 +2358,27 @@ pylong_int_from_string(const char *start, const char *end, PyLongObject **res)
23582358
{
23592359
PyObject *mod = PyImport_ImportModule("_pylong");
23602360
if (mod == NULL) {
2361-
return -1;
2361+
goto error;
23622362
}
23632363
PyObject *s = PyUnicode_FromStringAndSize(start, end-start);
23642364
if (s == NULL) {
2365-
return -1;
2365+
goto error;
23662366
}
23672367
PyObject *result = PyObject_CallMethod(mod, "int_from_string", "O", s);
23682368
Py_DECREF(s);
23692369
Py_DECREF(mod);
23702370
if (result == NULL) {
2371-
return -1;
2371+
goto error;
23722372
}
23732373
if (!PyLong_Check(result)) {
23742374
PyErr_SetString(PyExc_TypeError, "an integer is required");
2375-
return -1;
2375+
goto error;
23762376
}
23772377
*res = (PyLongObject *)result;
23782378
return 0;
2379+
error:
2380+
*res = NULL;
2381+
return 0;
23792382
}
23802383
#endif /* WITH_PYLONG_MODULE */
23812384

0 commit comments

Comments
 (0)