enlargestrinfo-fix.diff
text/x-patch
Filename: enlargestrinfo-fix.diff
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/lib/stringinfo.c | 3 | 4 |
diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index b618b37..b01afbe 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -313,14 +313,13 @@ enlargeStringInfo(StringInfo str, int needed) * for efficiency, double the buffer size each time it overflows. * Actually, we might need to more than double it if 'needed' is big... */ - newlen = 2 * str->maxlen; + newlen = 2 * (Size)str->maxlen; /* avoid integer overflow */ while (needed > newlen) newlen = 2 * newlen; /* - * Clamp to the limit in case we went past it. Note we are assuming here - * that limit <= INT_MAX/2, else the above loop could overflow. We will - * still have newlen >= needed. + * Clamp to the limit in case we went past it. We will still have + * newlen >= needed. */ if (newlen > limit) newlen = limit;