Commit 2aadb9c
committed
pp_sort: avoid potential I32 overflow from the comparator
Coverity says:
CID 584092: Integer handling issues (INTEGER_OVERFLOW)
Expression "result", where "Perl_SvIV(my_perl, *my_perl->Istack_sp)" is known to be equal to 0, overflows the type of "result", which is type "I32".
The sort comparison function returns IV (a Perl integer), but all the
sorting routines in this file want to work with I32. Instead of
converting (and possibly truncating) the value directly, normalize the
result to -1/0/1, which fits in any integer type.1 parent d7c5601 commit 2aadb9c
1 file changed
+15
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1167 | 1167 | | |
1168 | 1168 | | |
1169 | 1169 | | |
1170 | | - | |
1171 | 1170 | | |
1172 | 1171 | | |
1173 | 1172 | | |
| |||
1191 | 1190 | | |
1192 | 1191 | | |
1193 | 1192 | | |
1194 | | - | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1195 | 1198 | | |
1196 | 1199 | | |
1197 | 1200 | | |
| |||
1206 | 1209 | | |
1207 | 1210 | | |
1208 | 1211 | | |
1209 | | - | |
1210 | 1212 | | |
1211 | 1213 | | |
1212 | 1214 | | |
| |||
1256 | 1258 | | |
1257 | 1259 | | |
1258 | 1260 | | |
1259 | | - | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
1260 | 1266 | | |
1261 | 1267 | | |
1262 | 1268 | | |
| |||
1273 | 1279 | | |
1274 | 1280 | | |
1275 | 1281 | | |
1276 | | - | |
1277 | 1282 | | |
1278 | 1283 | | |
1279 | 1284 | | |
| |||
1291 | 1296 | | |
1292 | 1297 | | |
1293 | 1298 | | |
1294 | | - | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1295 | 1304 | | |
1296 | 1305 | | |
1297 | 1306 | | |
| |||
0 commit comments