Message329014
Sorry, Stefan Behnel, I still don't get it. alloc will always bigger than size after the if else case:
if (size < alloc / 2) {
/* Major downsize; resize down to exact size. */
alloc = size + 1;
}
else if (size < alloc) {
/* Within allocated size; quick exit */
return 0;
}
else if (size <= alloc * 1.125) {
/* Moderate upsize; overallocate similar to list_resize() */
alloc = size + (size >> 3) + (size < 9 ? 3 : 6);
}
else {
/* Major upsize; resize up to exact size */
alloc = size + 1;
}
Since we limit the alloc at:
if (alloc > PY_SIZE_MAX / sizeof(Py_UCS4))
goto overflow;
whenever size > PY_SIZE_MAX / sizeof(Py_UCS4) at first will cause alloc overflow. So why not limit size to PY_SIZE_MAX / sizeof(Py_UCS4) at the beginning? |
|
Date |
User |
Action |
Args |
2018-10-31 20:22:15 | Windson Yang | set | recipients:
+ Windson Yang, gregory.p.smith, scoder, vstinner |
2018-10-31 20:22:15 | Windson Yang | set | messageid: <1541017335.3.0.788709270274.issue34912@psf.upfronthosting.co.za> |
2018-10-31 20:22:15 | Windson Yang | link | issue34912 messages |
2018-10-31 20:22:15 | Windson Yang | create | |
|