Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c34696e

Browse files
committed
pythongh-127740: NULL at the end is mapped to 37
1 parent 6cc9305 commit c34696e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Objects/bytesobject.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,16 +2540,14 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
25402540
goto error;
25412541
}
25422542
str++;
2543-
2544-
/* Check if we have a second digit */
2545-
if (str >= end) {
2546-
invalid_char = -1;
2547-
goto error;
2548-
}
2549-
25502543
bot = _PyLong_DigitValue[*str];
25512544
if (bot >= 16) {
2552-
invalid_char = str - PyUnicode_1BYTE_DATA(string);
2545+
/* NULL at the end of the string */
2546+
if (bot == 37){
2547+
invalid_char = -1;
2548+
} else {
2549+
invalid_char = str - PyUnicode_1BYTE_DATA(string);
2550+
}
25532551
goto error;
25542552
}
25552553
str++;

0 commit comments

Comments
 (0)