-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
https://github.com/NGRsoftlab/cpython/blob/main/Modules/_io/bytesio.c#L158
size_t alloc = PyBytes_GET_SIZE(self->buf);
/* skipped for short */
if (alloc > ((size_t)-1) / sizeof(char))
goto overflow;This code is useless and goto is unreachable, because of false condition:
- 'alloc' has a type 'size_t' with minimum value '0' and a maximum value of size_t ('18446744073709551615' on x86_64)
- ((size_t)-1) is a maximum value of size_t ('18446744073709551615' on x86_64)
- size_t is built-in type for C
- sizeof(char) is always 1 in C
Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error