Title: [294109] trunk/Source/WebKit
Revision
294109
Author
[email protected]
Date
2022-05-12 10:43:34 -0700 (Thu, 12 May 2022)

Log Message

[GTK][WPE] Do not return pointer to disposed timezone string
https://bugs.webkit.org/show_bug.cgi?id=240327

Reviewed by Michael Catanzaro.

Store time zone name in CString to avoid returning pointer to a temp string which was
disposed before returning from webkit_web_context_get_time_zone_override.

No new tests. Covered by existing unit tests.

* UIProcess/API/glib/WebKitWebContext.cpp:
(webkitWebContextSetProperty):
(webkitWebContextConstructed):
(webkit_web_context_get_time_zone_override):
(webkit_web_context_set_time_zone_override): Deleted this function as the time zone can
only be overridden during context construction.
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/wpe/WebKitWebContext.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (294108 => 294109)


--- trunk/Source/WebKit/ChangeLog	2022-05-12 17:43:27 UTC (rev 294108)
+++ trunk/Source/WebKit/ChangeLog	2022-05-12 17:43:34 UTC (rev 294109)
@@ -1,3 +1,24 @@
+2022-05-12  Yury Semikhatsky  <[email protected]>
+
+        [GTK][WPE] Do not return pointer to disposed timezone string
+        https://bugs.webkit.org/show_bug.cgi?id=240327
+
+        Reviewed by Michael Catanzaro.
+
+        Store time zone name in CString to avoid returning pointer to a temp string which was
+        disposed before returning from webkit_web_context_get_time_zone_override.
+
+        No new tests. Covered by existing unit tests.
+
+        * UIProcess/API/glib/WebKitWebContext.cpp:
+        (webkitWebContextSetProperty):
+        (webkitWebContextConstructed):
+        (webkit_web_context_get_time_zone_override):
+        (webkit_web_context_set_time_zone_override): Deleted this function as the time zone can
+        only be overridden during context construction.
+        * UIProcess/API/gtk/WebKitWebContext.h:
+        * UIProcess/API/wpe/WebKitWebContext.h:
+
 2022-05-12  Olivier Blin  <[email protected]>
 
         REGRESSION(r291038) [GTK][WPE] Fix build without remote inspector

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp (294108 => 294109)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp	2022-05-12 17:43:27 UTC (rev 294108)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp	2022-05-12 17:43:34 UTC (rev 294109)
@@ -248,7 +248,7 @@
 
     WebKitMemoryPressureSettings* memoryPressureSettings;
 
-    String timeZoneOverride;
+    CString timeZoneOverride;
 };
 
 static guint signals[LAST_SIGNAL] = { 0, };
@@ -393,8 +393,9 @@
         break;
     }
     case PROP_TIME_ZONE_OVERRIDE: {
-        if (const auto* override = g_value_get_string(value))
-            webkit_web_context_set_time_zone_override(context, override);
+        const auto* timeZone = g_value_get_string(value);
+        if (isTimeZoneValid(timeZone))
+            context->priv->timeZoneOverride = timeZone;
         break;
     }
     default:
@@ -425,7 +426,7 @@
         // Once the settings have been passed to the ProcessPoolConfiguration, we don't need them anymore so we can free them.
         g_clear_pointer(&priv->memoryPressureSettings, webkit_memory_pressure_settings_free);
     }
-    configuration.setTimeZoneOverride(priv->timeZoneOverride);
+    configuration.setTimeZoneOverride(String::fromUTF8(priv->timeZoneOverride.data(), priv->timeZoneOverride.length()));
 
     if (!priv->websiteDataManager)
         priv->websiteDataManager = adoptGRef(webkit_website_data_manager_new("local-storage-directory", priv->localStorageDirectory.data(), nullptr));
@@ -1871,24 +1872,6 @@
 #endif
 
 /**
- * webkit_web_context_set_time_zone_override:
- * @context: a #WebKitWebContext
- * @time_zone_override: value to set
- *
- * Set the #WebKitWebContext:time-zone-override property. Refer to the IANA database for valid
- * specifiers, https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- *
- * Since: 2.38
- */
-void webkit_web_context_set_time_zone_override(WebKitWebContext* context, const gchar* timeZoneOverride)
-{
-    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
-    g_return_if_fail(isTimeZoneValid(timeZoneOverride));
-
-    context->priv->timeZoneOverride = String::fromUTF8(timeZoneOverride);
-}
-
-/**
  * webkit_web_context_get_time_zone_override:
  * @context: a #WebKitWebContext
  *
@@ -1900,7 +1883,7 @@
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), nullptr);
 
-    return context->priv->timeZoneOverride.utf8().data();
+    return context->priv->timeZoneOverride.data();
 }
 
 void webkitWebContextInitializeNotificationPermissions(WebKitWebContext* context)

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h (294108 => 294109)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h	2022-05-12 17:43:27 UTC (rev 294108)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h	2022-05-12 17:43:34 UTC (rev 294109)
@@ -302,10 +302,6 @@
 WEBKIT_API gboolean
 webkit_web_context_get_use_system_appearance_for_scrollbars (WebKitWebContext      *context);
 
-WEBKIT_API void
-webkit_web_context_set_time_zone_override           (WebKitWebContext              *context,
-                                                     const gchar                   *time_zone_override);
-
 WEBKIT_API const gchar*
 webkit_web_context_get_time_zone_override           (WebKitWebContext              *context);
 

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h (294108 => 294109)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h	2022-05-12 17:43:27 UTC (rev 294108)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h	2022-05-12 17:43:34 UTC (rev 294109)
@@ -291,10 +291,6 @@
 webkit_web_context_send_message_to_all_extensions   (WebKitWebContext              *context,
                                                      WebKitUserMessage             *message);
 
-WEBKIT_API void
-webkit_web_context_set_time_zone_override           (WebKitWebContext              *context,
-                                                     const gchar                   *time_zone_override);
-
 WEBKIT_API const gchar*
 webkit_web_context_get_time_zone_override           (WebKitWebContext              *context);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to