We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a5f7e02 commit fd1444eCopy full SHA for fd1444e
1 file changed
Objects/longobject.c
@@ -1046,8 +1046,14 @@ _PyLong_AsByteArray(PyLongObject* v,
1046
just above didn't get to ensure there's a sign bit, and the
1047
loop below wouldn't add one either. Make sure a sign bit
1048
exists. */
1049
- unsigned char msb = *(p - pincr);
1050
- int sign_bit_set = msb >= 0x80;
+ int sign_bit_set;
+ if (n > 0) {
1051
+ unsigned char msb = *(p - pincr);
1052
+ sign_bit_set = msb >= 0x80;
1053
+ }
1054
+ else {
1055
+ sign_bit_set = 0;
1056
1057
assert(accumbits == 0);
1058
if (sign_bit_set == do_twos_comp)
1059
return 0;
0 commit comments