Skip to content

Commit eecd6a8

Browse files
committed
gh-106693: Explicitly mark ob_sval as unsigned char to avoid UB
Signed-off-by: Pablo Galindo <[email protected]>
1 parent 3e23fa7 commit eecd6a8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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.
@@ -32,7 +32,7 @@ PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
3232
#define _PyBytes_CAST(op) \
3333
(assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))
3434

35-
static inline char* PyBytes_AS_STRING(PyObject *op)
35+
static inline unsigned char* PyBytes_AS_STRING(PyObject *op)
3636
{
3737
return _PyBytes_CAST(op)->ob_sval;
3838
}

0 commit comments

Comments
 (0)