From 3cddc44be34485ba7f835387b50d12ae6bc897d9 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Mon, 3 Apr 2023 05:56:33 -0700 Subject: [PATCH] Cherry-pick 262504@main (6a3c0713422d). https://bugs.webkit.org/show_bug.cgi?id=254913 [GLib] Crash opening webkit://gpu when XDG_CURRENT_DESKTOP is undefined https://bugs.webkit.org/show_bug.cgi?id=254913 Reviewed by Philippe Normand. * Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp: (WebKit::WebKitProtocolHandler::handleGPU): Check whether picking XDG_CURRENT_DESKTOP from the environment returns non-null and the variable is not empty before using it. Canonical link: https://commits.webkit.org/262504@main --- Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp b/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp index abb9dea0487f..e1816aaf10f4 100644 --- a/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp +++ b/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp @@ -213,7 +213,8 @@ void WebKitProtocolHandler::handleGPU(WebKitURISchemeRequest* request) addTableRow(versionObject, "Operating system"_s, makeString(osName.sysname, ' ', osName.release, ' ', osName.version, ' ', osName.machine)); #endif - addTableRow(versionObject, "Desktop"_s, makeString(g_getenv("XDG_CURRENT_DESKTOP"))); + const char* desktopName = g_getenv("XDG_CURRENT_DESKTOP"); + addTableRow(versionObject, "Desktop"_s, (desktopName && *desktopName) ? makeString(desktopName) : "Unknown"_s); #if USE(CAIRO) addTableRow(versionObject, "Cairo version"_s, makeString(CAIRO_VERSION_STRING, " (build) "_s, cairo_version_string(), " (runtime)"_s));