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 18dfc1d commit e234ea6Copy full SHA for e234ea6
1 file changed
Objects/longobject.c
@@ -1143,8 +1143,14 @@ _PyLong_AsByteArray(PyLongObject* v,
1143
just above didn't get to ensure there's a sign bit, and the
1144
loop below wouldn't add one either. Make sure a sign bit
1145
exists. */
1146
- unsigned char msb = *(p - pincr);
1147
- int sign_bit_set = msb >= 0x80;
+ int sign_bit_set;
+ if (n > 0) {
1148
+ unsigned char msb = *(p - pincr);
1149
+ sign_bit_set = msb >= 0x80;
1150
+ }
1151
+ else {
1152
+ sign_bit_set = 0;
1153
1154
assert(accumbits == 0);
1155
if (sign_bit_set == do_twos_comp)
1156
return 0;
0 commit comments