mshtml: Handle aCount < buf_size case correctly in nsIInputStream::Read implementation.
This commit is contained in:
parent
372a0f24a2
commit
db0bd528e7
|
@ -152,18 +152,21 @@ static nsresult NSAPI nsInputStream_Read(nsIInputStream *iface, char *aBuf, PRUi
|
||||||
PRUint32 *_retval)
|
PRUint32 *_retval)
|
||||||
{
|
{
|
||||||
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
||||||
|
DWORD read = aCount;
|
||||||
|
|
||||||
TRACE("(%p)->(%p %d %p)\n", This, aBuf, aCount, _retval);
|
TRACE("(%p)->(%p %d %p)\n", This, aBuf, aCount, _retval);
|
||||||
|
|
||||||
/* Gecko always calls Read with big enough buffer */
|
if(read > This->buf_size)
|
||||||
if(aCount < This->buf_size)
|
read = This->buf_size;
|
||||||
FIXME("aCount < This->buf_size\n");
|
|
||||||
|
|
||||||
*_retval = This->buf_size;
|
if(read) {
|
||||||
if(This->buf_size)
|
memcpy(aBuf, This->buf, read);
|
||||||
memcpy(aBuf, This->buf, This->buf_size);
|
if(read < This->buf_size)
|
||||||
This->buf_size = 0;
|
memmove(This->buf, This->buf+read, This->buf_size-read);
|
||||||
|
This->buf_size -= read;
|
||||||
|
}
|
||||||
|
|
||||||
|
*_retval = read;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue