Check Py{Bytes,String}_AsStringAndSize() for failure

PyBytes_AsStringAndSize() and PyString_AsStringAndSize() were not
being checked for failure.

Closes #1349.
This commit is contained in:
Zackery Spytz 2020-01-09 21:14:12 -07:00
commit 6adf19b52f
2 changed files with 8 additions and 3 deletions

View file

@ -32,9 +32,11 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
if (alloc)
*alloc = SWIG_NEWOBJ;
%#endif
PyBytes_AsStringAndSize(obj, &cstr, &len);
if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1)
return SWIG_TypeError;
%#else
PyString_AsStringAndSize(obj, &cstr, &len);
if (PyString_AsStringAndSize(obj, &cstr, &len) == -1)
return SWIG_TypeError;
%#endif
if (cptr) {
if (alloc) {