Skip to content

Commit a754be4

Browse files
committed
Fix for empty format string
1 parent 800e85f commit a754be4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Objects/memoryobject.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,9 +3134,10 @@ memory_richcompare(PyObject *v, PyObject *w, int op)
31343134
if (*format == '@') {
31353135
format++;
31363136
}
3137-
// Include only formats known by struct, exclude formats "d" (double),
3138-
// "f" (float), "e" (16-bit float)
3139-
can_compare_ptr = (strchr("bBchHiIlLnNPqQ?", format[0]) != NULL
3137+
// Include only formats known by struct, exclude formats
3138+
// "d" (double), "f" (float) and "e" (16-bit float).
3139+
can_compare_ptr = (format[0] != 0
3140+
&& strchr("bBchHiIlLnNPqQ?", format[0]) != NULL
31403141
&& format[1] == 0);
31413142
}
31423143
else {

0 commit comments

Comments
 (0)