Commit 8e90d664 authored by Christian Heimes's avatar Christian Heimes

Fixed issue #1973: bytes.fromhex('') raises SystemError

parent b6b762fb
...@@ -2772,7 +2772,7 @@ string_fromhex(PyObject *cls, PyObject *args) ...@@ -2772,7 +2772,7 @@ string_fromhex(PyObject *cls, PyObject *args)
} }
buf[j++] = (top << 4) + bot; buf[j++] = (top << 4) + bot;
} }
if (_PyString_Resize(&newstring, j) < 0) if (j != byteslen && _PyString_Resize(&newstring, j) < 0)
goto error; goto error;
return newstring; return newstring;
...@@ -2788,7 +2788,7 @@ string_getnewargs(PyStringObject *v) ...@@ -2788,7 +2788,7 @@ string_getnewargs(PyStringObject *v)
return Py_BuildValue("(s#)", v->ob_sval, Py_SIZE(v)); return Py_BuildValue("(s#)", v->ob_sval, Py_SIZE(v));
} }
static PyMethodDef static PyMethodDef
string_methods[] = { string_methods[] = {
{"__getnewargs__", (PyCFunction)string_getnewargs, METH_NOARGS}, {"__getnewargs__", (PyCFunction)string_getnewargs, METH_NOARGS},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment