Bug 240327 - [GTK][WPE] Do not return pointer to disposed timezone string
Summary: [GTK][WPE] Do not return pointer to disposed timezone string
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yury Semikhatsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-11 18:20 PDT by Yury Semikhatsky
Modified: 2022-05-12 10:45 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.93 KB, patch)
2022-05-11 18:22 PDT, Yury Semikhatsky
no flags Details | Formatted Diff | Diff
Patch (3.97 KB, patch)
2022-05-11 19:19 PDT, Yury Semikhatsky
no flags Details | Formatted Diff | Diff
Patch (5.85 KB, patch)
2022-05-12 10:03 PDT, Yury Semikhatsky
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yury Semikhatsky 2022-05-11 18:20:36 PDT
[GTK][WPE] Do not return pointer to disposed timezone string
Comment 1 Yury Semikhatsky 2022-05-11 18:22:04 PDT
Created attachment 459196 [details]
Patch
Comment 2 Yury Semikhatsky 2022-05-11 19:19:23 PDT
Created attachment 459201 [details]
Patch
Comment 3 Michael Catanzaro 2022-05-12 06:42:23 PDT
Comment on attachment 459201 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=459201&action=review

> Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:396
> +        if (const auto* override = g_value_get_string(value); isTimeZoneValid(override))

IMO it's more readable if you use two ifs rather than a semicolon.

> Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:-1883
> -/**
> - * 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)

Hm, why are you removing this?

Since it's declared in public headers, you need to remove it from the headers too.

> Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:-1888
> -    context->priv->timeZoneOverride = String::fromUTF8(timeZoneOverride);

If you don't want to remove the setter, I think you can just do:

context->priv->timeZoneOverride = timeZoneOverride

?
Comment 4 Yury Semikhatsky 2022-05-12 09:55:46 PDT
Comment on attachment 459201 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=459201&action=review

>> Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:396
>> +        if (const auto* override = g_value_get_string(value); isTimeZoneValid(override))
> 
> IMO it's more readable if you use two ifs rather than a semicolon.

Changed. I personally prefer single statement per line but in another review[1] I was suggested reduce the scope of variables to the if block when possible.


[1] https://bugs.webkit.org/show_bug.cgi?id=213884#c37

>> Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:-1883
>> -void webkit_web_context_set_time_zone_override(WebKitWebContext* context, const gchar* timeZoneOverride)
> 
> Hm, why are you removing this?
> 
> Since it's declared in public headers, you need to remove it from the headers too.

Removed it from the header as well. There is no point in this method as calling it after context has been created will not update WebProcessPool configuration (and that is intentional as we don't want to have mixed time zones for pages in one pool).
Comment 5 Yury Semikhatsky 2022-05-12 10:03:32 PDT
Created attachment 459236 [details]
Patch
Comment 6 Michael Catanzaro 2022-05-12 10:08:33 PDT
(In reply to Yury Semikhatsky from comment #4)
> Removed it from the header as well. There is no point in this method as
> calling it after context has been created will not update WebProcessPool
> configuration (and that is intentional as we don't want to have mixed time
> zones for pages in one pool).

Ah yes, I see the property is construct only, so that's a good clue that there should definitely not be a setter function.

Another concern: removing it without breaking any tests reveals that there was no API test for it, which would have caught that it could not work.
Comment 7 EWS 2022-05-12 10:45:47 PDT
Committed r294109 (250492@main): <https://commits.webkit.org/250492@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 459236 [details].