backing out patch for bug 278786. it breaks read(-1).

This commit is contained in:
cbiesinger%web.de 2005-01-22 00:16:44 +00:00
parent e8ace4f904
commit bf9a5d31f9

View File

@ -64,15 +64,20 @@ nsScriptableInputStream::Available(PRUint32 *_retval) {
NS_IMETHODIMP
nsScriptableInputStream::Read(PRUint32 aCount, char **_retval) {
nsresult rv = NS_OK;
PRUint32 count = 0;
char *buffer = nsnull;
if (!mInputStream) return NS_ERROR_NOT_INITIALIZED;
buffer = (char*)nsMemory::Alloc(aCount+1); // make room for '\0'
rv = mInputStream->Available(&count);
if (NS_FAILED(rv)) return rv;
count = PR_MIN(count, aCount);
buffer = (char*)nsMemory::Alloc(count+1); // make room for '\0'
if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
PRUint32 amtRead = 0;
rv = mInputStream->Read(buffer, aCount, &amtRead);
rv = mInputStream->Read(buffer, count, &amtRead);
if (NS_FAILED(rv)) {
nsMemory::Free(buffer);
return rv;