From 6628ea7ee45a5db84fe06069c8bdd7660ecdb073 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Tue, 10 Dec 2024 15:09:18 +0530 Subject: [PATCH] gh-127740: Check if we had a second digit --- Objects/bytesobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 474a625143e9a7..533089d25cd73a 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2543,8 +2543,8 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray) bot = _PyLong_DigitValue[*str]; if (bot >= 16) { - /* NULL at the end of the string */ - if (bot == 37){ + /* Check if we had a second digit */ + if (str >= end){ invalid_char = -1; } else { invalid_char = str - PyUnicode_1BYTE_DATA(string);