From: Pablo Galindo Salgado Date: Thu, 7 May 2026 19:06:53 +0000 (+0100) Subject: gh-106693: Explicitly mark ob_sval as unsigned char to avoid UB (#106826) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fbba343622c9e4a38c8ef0f0b0e311164394d76a;p=thirdparty%2FPython%2Fcpython.git gh-106693: Explicitly mark ob_sval as unsigned char to avoid UB (#106826) Signed-off-by: Pablo Galindo --- diff --git a/Include/cpython/bytesobject.h b/Include/cpython/bytesobject.h index 85bc2b827df8..550b5fcb952e 100644 --- a/Include/cpython/bytesobject.h +++ b/Include/cpython/bytesobject.h @@ -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. @@ -20,7 +20,7 @@ PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, 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; }