mshtml: Handle aCount < buf_size case correctly in nsIInputStream::Read implementation.

This commit is contained in:
Jacek Caban 2009-05-11 23:08:24 +02:00 committed by Alexandre Julliard
parent 372a0f24a2
commit db0bd528e7
1 changed files with 10 additions and 7 deletions

View File

@ -152,18 +152,21 @@ static nsresult NSAPI nsInputStream_Read(nsIInputStream *iface, char *aBuf, PRUi
PRUint32 *_retval)
{
nsProtocolStream *This = NSINSTREAM_THIS(iface);
DWORD read = aCount;
TRACE("(%p)->(%p %d %p)\n", This, aBuf, aCount, _retval);
/* Gecko always calls Read with big enough buffer */
if(aCount < This->buf_size)
FIXME("aCount < This->buf_size\n");
if(read > This->buf_size)
read = This->buf_size;
*_retval = This->buf_size;
if(This->buf_size)
memcpy(aBuf, This->buf, This->buf_size);
This->buf_size = 0;
if(read) {
memcpy(aBuf, This->buf, read);
if(read < This->buf_size)
memmove(This->buf, This->buf+read, This->buf_size-read);
This->buf_size -= read;
}
*_retval = read;
return NS_OK;
}