From eecd6a8cd494d650d7fe2407f7d1e6fee4b28f19 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Mon, 17 Jul 2023 16:47:47 +0100 Subject: [PATCH] gh-106693: Explicitly mark ob_sval as unsigned char to avoid UB Signed-off-by: Pablo Galindo --- Include/cpython/bytesobject.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/cpython/bytesobject.h b/Include/cpython/bytesobject.h index 0af4c83b1e5bc7..60198c02c08ca4 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. @@ -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; }