This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Windson Yang
Recipients Windson Yang, gregory.p.smith, scoder, vstinner
Date 2018-10-31.20:22:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1541017335.3.0.788709270274.issue34912@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2018-10-31 20:22:15Windson Yangsetrecipients: + Windson Yang, gregory.p.smith, scoder, vstinner
2018-10-31 20:22:15Windson Yangsetmessageid: <1541017335.3.0.788709270274.issue34912@psf.upfronthosting.co.za>
2018-10-31 20:22:15Windson Yanglinkissue34912 messages
2018-10-31 20:22:15Windson Yangcreate