File tree 1 file changed +7
-6
lines changed
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)
313
313
* for efficiency, double the buffer size each time it overflows.
314
314
* Actually, we might need to more than double it if 'needed' is big...
315
315
*/
316
- newlen = 2 * str -> maxlen ;
317
- while (needed > newlen )
316
+ newlen = 2 * ( Size ) str -> maxlen ;
317
+ while (( Size ) needed > newlen )
318
318
newlen = 2 * newlen ;
319
319
320
320
/*
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.
324
325
*/
325
326
if (newlen > limit )
326
327
newlen = limit ;
327
328
328
- str -> data = (char * ) repalloc_huge (str -> data , ( Size ) newlen );
329
+ str -> data = (char * ) repalloc_huge (str -> data , newlen );
329
330
330
331
str -> maxlen = newlen ;
331
332
}
You can’t perform that action at this time.
0 commit comments