Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d28f59

Browse files
committed
Add asserts to PyBytes_AS_STRING and PyBytes_GET_SIZE.
1 parent 27ff74d commit 2d28f59

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Include/bytesobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
4141
PyAPI_FUNC(int) PyBytes_Resize(PyObject *, Py_ssize_t);
4242

4343
/* Macros, trading safety for speed */
44-
#define PyBytes_AS_STRING(self) (((PyBytesObject *)(self))->ob_bytes)
45-
#define PyBytes_GET_SIZE(self) (((PyBytesObject *)(self))->ob_size)
44+
#define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes)
45+
#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_size)
4646

4747
#ifdef __cplusplus
4848
}

0 commit comments

Comments
 (0)