Make sure to wrap a buffered stream around the stream we're passed before

sending it to the parser (which expects a buffered stream).  Bug 287409,
r=darin, sr=jst


git-svn-id: svn://10.0.0.236/trunk@194892 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2006-04-20 03:39:03 +00:00
parent f839c310fc
commit 7a870938fd

View File

@ -63,6 +63,9 @@
#include "nsCRT.h"
#include "nsIDOMEventReceiver.h"
#include "nsLoadListenerProxy.h"
#include "nsStreamUtils.h"
#include "nsNetCID.h"
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static const char* kLoadAsData = "loadAsData";
@ -487,7 +490,17 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
(nsCRT::strcmp(contentType, "application/xhtml+xml") != 0))
return NS_ERROR_NOT_IMPLEMENTED;
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
nsresult rv;
nsCOMPtr<nsIBufferedInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(stream)) {
bufferedStream = do_CreateInstance(NS_BUFFEREDINPUTSTREAM_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = bufferedStream->Init(stream, 4096);
NS_ENSURE_SUCCESS(rv, rv);
stream = bufferedStream;
}
nsCOMPtr<nsIPrincipal> principal;
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);