mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1839177 - Always call OnStopRequest after OnStartRequest even with failures in OnDataAvailable in nsUnknownDecoder::ConvertEncodedData r=necko-reviewers,kershaw
The contract is that after calling OnStartRequest once we then MUST call OnStopRequest, once. Differential Revision: https://phabricator.services.mozilla.com/D181387
This commit is contained in:
parent
404865765b
commit
71d6172ae6
@ -13,6 +13,7 @@
|
||||
|
||||
#include "nsIMIMEService.h"
|
||||
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "nsIViewSourceChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIForcePendingChannel.h"
|
||||
@ -760,11 +761,16 @@ nsresult nsUnknownDecoder::ConvertEncodedData(nsIRequest* request,
|
||||
|
||||
if (listener) {
|
||||
listener->OnStartRequest(request);
|
||||
auto callOnStopRequest =
|
||||
MakeScopeExit([&] { listener->OnStopRequest(request, rv); });
|
||||
|
||||
if (length) {
|
||||
nsCOMPtr<nsIStringInputStream> rawStream =
|
||||
do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID);
|
||||
if (!rawStream) return NS_ERROR_FAILURE;
|
||||
if (!rawStream) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = rawStream->SetData((const char*)data, length);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -772,8 +778,7 @@ nsresult nsUnknownDecoder::ConvertEncodedData(nsIRequest* request,
|
||||
rv = listener->OnDataAvailable(request, rawStream, 0, length);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
listener->OnStopRequest(request, NS_OK);
|
||||
// implicit call to OnStopRequest by exiting the scope
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
Loading…
Reference in New Issue
Block a user