[PATCH 3/4] mshtml: Abort on a cancelled async request properly.

Gabriel Ivăncescu gabrielopcode at gmail.com
Thu May 26 11:54:28 CDT 2022


Gecko can cancel an async request sometime between async_start_doc_binding
registers it and on_start_nsrequest actually processes it. The latter should
not attempt to continue in this case.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/mshtml/binding.h  | 1 +
 dlls/mshtml/navigate.c | 4 ++++
 dlls/mshtml/nsio.c     | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/dlls/mshtml/binding.h b/dlls/mshtml/binding.h
index 26a337f..9a04386 100644
--- a/dlls/mshtml/binding.h
+++ b/dlls/mshtml/binding.h
@@ -51,6 +51,7 @@ typedef struct {
     nsIURI *referrer;
     char *content_type;
     char *charset;
+    nsresult status;
     UINT32 response_status;
     char *response_status_text;
     REQUEST_METHOD request_method;
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index d5ec368..e6f2035 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -981,6 +981,10 @@ static HRESULT on_start_nsrequest(nsChannelBSC *This)
 {
     nsresult nsres;
 
+    /* Async request can be cancelled before we got to it */
+    if(NS_FAILED(This->nschannel->status))
+        return E_ABORT; /* FIXME: map status to HRESULT */
+
     This->nschannel->binding = This;
 
     /* FIXME: it's needed for http connections from BindToObject. */
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index e0b8bed..e1a1d6e 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -610,6 +610,9 @@ static nsresult NSAPI nsChannel_Cancel(nsIHttpChannel *iface, nsresult aStatus)
 
     TRACE("(%p)->(%08lx)\n", This, aStatus);
 
+    if(NS_FAILED(aStatus))
+        This->status = aStatus;
+
     if(This->binding && This->binding->bsc.binding)
         IBinding_Abort(This->binding->bsc.binding);
     else
-- 
2.34.1




More information about the wine-devel mailing list