Skip to content

Commit fbba343

Browse files
authored
gh-106693: Explicitly mark ob_sval as unsigned char to avoid UB (#106826)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent 9d07159 commit fbba343

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Include/cpython/bytesobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
typedef struct {
66
PyObject_VAR_HEAD
77
Py_DEPRECATED(3.11) Py_hash_t ob_shash;
8-
char ob_sval[1];
8+
unsigned char ob_sval[1];
99

1010
/* Invariants:
1111
* ob_sval contains space for 'ob_size+1' elements.
@@ -20,7 +20,7 @@ PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
2020
#define _PyBytes_CAST(op) \
2121
(assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))
2222

23-
static inline char* PyBytes_AS_STRING(PyObject *op)
23+
static inline unsigned char* PyBytes_AS_STRING(PyObject *op)
2424
{
2525
return _PyBytes_CAST(op)->ob_sval;
2626
}

0 commit comments

Comments
 (0)