commit: 9a3da3ed116c871fc0e06bdcfedfae5933695465
parent f8d6696b46e5f0fe8516a0c77780809a0897de42
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 26 Apr 2024 07:33:16 +0200
badwolf.c: Fix NULL dereference in WebViewCb_decide_policy
Found via GCC -fanalyzer
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/badwolf.c b/badwolf.c
@@ -366,8 +366,13 @@ WebViewCb_decide_policy(WebKitWebView *UNUSED(web_view),
WebKitURIRequest *uri = webkit_navigation_action_get_request(navigation_action);
const gchar *target_url = webkit_uri_request_get_uri(uri);
struct Client *browser = new_browser(target_url, old_browser);
+ int ret = badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE);
- badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE);
+ if(ret < 0)
+ {
+ fprintf(stderr, "badwolf: Error while opening <%s> in a new tab (badwolf_new_tab returned %d)\n", target_url, ret);
+ return FALSE;
+ }
webkit_web_view_load_uri(browser->webView, target_url);
webkit_policy_decision_ignore(decision);
}