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 7168e98 commit 8b5ce31Copy full SHA for 8b5ce31
1 file changed
Objects/longobject.c
@@ -1214,8 +1214,14 @@ _PyLong_AsByteArray(PyLongObject* v,
1214
just above didn't get to ensure there's a sign bit, and the
1215
loop below wouldn't add one either. Make sure a sign bit
1216
exists. */
1217
- unsigned char msb = *(p - pincr);
1218
- int sign_bit_set = msb >= 0x80;
+ int sign_bit_set;
+ if (n > 0) {
1219
+ unsigned char msb = *(p - pincr);
1220
+ sign_bit_set = msb >= 0x80;
1221
+ }
1222
+ else {
1223
+ sign_bit_set = 0;
1224
1225
assert(accumbits == 0);
1226
if (sign_bit_set == do_twos_comp)
1227
return 0;
0 commit comments