mirror of
https://github.com/python/cpython.git
synced 2026-04-14 07:41:00 +00:00
[3.14] gh-141370: Fix undefined behavior when using Py_ABS() (GH-141548) (GH-142301)
(cherry picked from commit 706fdda8b3)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
5e425c3f96
commit
ebeb07f132
6 changed files with 43 additions and 3 deletions
|
|
@ -310,7 +310,7 @@ w_PyLong(const PyLongObject *ob, char flag, WFILE *p)
|
|||
}
|
||||
if (!long_export.digits) {
|
||||
int8_t sign = long_export.value < 0 ? -1 : 1;
|
||||
uint64_t abs_value = Py_ABS(long_export.value);
|
||||
uint64_t abs_value = _Py_ABS_CAST(uint64_t, long_export.value);
|
||||
uint64_t d = abs_value;
|
||||
long l = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen,
|
|||
else {
|
||||
bytes_per_sep_group = 0;
|
||||
}
|
||||
|
||||
unsigned int abs_bytes_per_sep = Py_ABS(bytes_per_sep_group);
|
||||
unsigned int abs_bytes_per_sep = _Py_ABS_CAST(unsigned int, bytes_per_sep_group);
|
||||
Py_ssize_t resultlen = 0;
|
||||
if (bytes_per_sep_group && arglen > 0) {
|
||||
/* How many sep characters we'll be inserting. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue