[New-bugs-announce] [issue27473] bytes_concat seems to check overflow using undefined behaviour

Xiang Zhang report at bugs.python.org
Sat Jul 9 12:46:44 EDT 2016


New submission from Xiang Zhang:

bytes_concat uses following code to check overflow:

size = va.len + vb.len;
if (size < 0): {
    PyErr_NoMemory();
    goto done;
}

This is wrong since signed ints overflow is undefined bahaviour.

But one point is that Python's Makefile defines -fwrapv with gcc and
clang. So I am not sure this needs to be changed or not. But in other
parts of Python code I don't see any overflow check like this. I only
see pre-calculated overflow checks.

----------
messages: 270053
nosy: serhiy.storchaka, xiang.zhang
priority: normal
severity: normal
status: open
title: bytes_concat seems to check overflow using undefined behaviour

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27473>
_______________________________________


More information about the New-bugs-announce mailing list