From 480f3b7e9526d2219267d5426a7c997574846d59 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 23 Apr 2021 23:22:30 +0300 Subject: DocumentWidget: Crash after receiving a redirect The `GmRequest` object is destroyed after handling a redirect, but afterwards a check was still made to cache the request contents. IssueID #148 --- src/ui/documentwidget.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 6cf06f1e..f15d4e3b 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -2033,7 +2033,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) return iFalse; } else if (equalWidget_Command(cmd, w, "document.request.finished") && - pointerLabel_Command(cmd, "request") == d->request) { + d->request && pointerLabel_Command(cmd, "request") == d->request) { set_Block(&d->sourceContent, body_GmRequest(d->request)); if (!isSuccess_GmStatusCode(status_GmRequest(d->request))) { format_String(&d->sourceHeader, @@ -2048,7 +2048,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) checkResponse_DocumentWidget_(d); init_Anim(&d->scrollY.pos, d->initNormScrollY * size_GmDocument(d->doc).y); /* TODO: unless user already scrolled! */ d->state = ready_RequestState; - /* The response may be cached. */ { + /* The response may be cached. */ + if (d->request) { if (!equal_Rangecc(urlScheme_String(d->mod.url), "about") && startsWithCase_String(meta_GmRequest(d->request), "text/")) { setCachedResponse_History(d->mod.history, lockResponse_GmRequest(d->request)); -- cgit v1.2.3