Skip to content

Commit

Permalink
pythongh-106693: Explicitly mark ob_sval as unsigned char to avoid UB
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
pablogsal committed Jul 17, 2023
1 parent 3e23fa7 commit 89c88a2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Include/cpython/bytesobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
typedef struct {
PyObject_VAR_HEAD
Py_DEPRECATED(3.11) Py_hash_t ob_shash;
char ob_sval[1];
unsigned char ob_sval[1];

/* Invariants:
* ob_sval contains space for 'ob_size+1' elements.
Expand All @@ -32,7 +32,7 @@ PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
#define _PyBytes_CAST(op) \
(assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))

static inline char* PyBytes_AS_STRING(PyObject *op)
static inline unsigned char* PyBytes_AS_STRING(PyObject *op)
{
return _PyBytes_CAST(op)->ob_sval;
}
Expand Down

0 comments on commit 89c88a2

Please sign in to comment.