Bugfix for out of control growth of internal buffer under certain error conditions.

git-svn-id: svn://10.0.0.236/trunk@27242 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cata%netscape.com
1999-04-13 00:08:26 +00:00
parent bca10111d4
commit ef9e897f6b

View File

@@ -456,7 +456,12 @@ NS_IMETHODIMP nsDecoderSupport::Convert(const char * aSrc,
if ((res == NS_OK_UDEC_MOREINPUT) && (bcw == 0)) {
// not enough input to convert even a single char: repeat!
DoubleBuffer();
if (mBufferLength <= 32) DoubleBuffer();
else {
// somehow we got into an error state and the buffer is growing out of control
res = NS_ERROR_UNEXPECTED;
break;
}
} else {
if (bcr < buffLen) {
// we didn't convert that residual data - unfill the buffer
@@ -482,7 +487,15 @@ NS_IMETHODIMP nsDecoderSupport::Convert(const char * aSrc,
if (res == NS_OK_UDEC_MOREINPUT) {
bcr = srcEnd - src;
// make sure buffer is large enough
while (bcr > mBufferCapacity) DoubleBuffer();
while (bcr > mBufferCapacity) {
if (mBufferLength <= 32) DoubleBuffer();
else {
// somehow we got into an error state and the buffer is growing out of control
res = NS_ERROR_UNEXPECTED;
break;
}
}
FillBuffer(&src, bcr);
}
}