FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-71810: Fix _PyLong_AsByteArray() undefined behavior (GH-138873) by miss-islington · Pull Request #138884 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 8 additions & 2 deletions Objects/longobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,14 @@ _PyLong_AsByteArray(PyLongObject* v,
just above didn't get to ensure there's a sign bit, and the
loop below wouldn't add one either. Make sure a sign bit
exists. */
unsigned char msb = *(p - pincr);
int sign_bit_set = msb >= 0x80;
int sign_bit_set;
if (n > 0) {
unsigned char msb = *(p - pincr);
sign_bit_set = msb >= 0x80;
}
else {
sign_bit_set = 0;
}
assert(accumbits == 0);
if (sign_bit_set == do_twos_comp)
return 0;
Expand Down
Loading

Back | FazBrowse Home | New Git URL