File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -313,19 +313,20 @@ enlargeStringInfo(StringInfo str, int needed)
313313 * for efficiency, double the buffer size each time it overflows.
314314 * Actually, we might need to more than double it if 'needed' is big...
315315 */
316- newlen = 2 * str -> maxlen ;
317- while (needed > newlen )
316+ newlen = 2 * ( Size ) str -> maxlen ;
317+ while (( Size ) needed > newlen )
318318 newlen = 2 * newlen ;
319319
320320 /*
321- * Clamp to the limit in case we went past it. Note we are assuming here
322- * that limit <= INT_MAX/2, else the above loop could overflow. We will
323- * still have newlen >= needed.
321+ * Clamp to the limit in case we went past it. (We used to depend on
322+ * limit <= INT32_MAX/2, to avoid overflow in the loop above; we no longer
323+ * depend on that, but if "needed" and str->maxlen ever become wider, we
324+ * will need similar caution here.) We will still have newlen >= needed.
324325 */
325326 if (newlen > limit )
326327 newlen = limit ;
327328
328- str -> data = (char * ) repalloc_huge (str -> data , ( Size ) newlen );
329+ str -> data = (char * ) repalloc_huge (str -> data , newlen );
329330
330331 str -> maxlen = newlen ;
331332}
You can’t perform that action at this time.
0 commit comments