WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
281667
[GTK][WPE] Use std::array to store GObject signal and property identifiers
https://bugs.webkit.org/show_bug.cgi?id=281667
Summary
[GTK][WPE] Use std::array to store GObject signal and property identifiers
Adrian Perez
Reported
2024-10-17 07:19:03 PDT
As per the usual GObject practice, we use the following C-ism when defining identifiers for object signals and properties, and to store their identifiers (an “unsigned int” for signals, and a “GParamSpec* for properties): enum { PROP_0, PROP_FOO, PROP_BAR, N_PROPERTIES }; static GParamSpec *sObjProperties[N_PROPERTIES] = { nullptr, }; Then, the sObjProperties array is subscripted in the class initializer at the moment properties (or signals) are created and installed in the class: sObjProperties[PROP_FOO] = g_param_spec_...( ... ); sObjProperties[PROP_BAR] = g_param_spec_...( ... ); g_object_class_install_properties(objectClass, N_PROPERTIES, sObjProperties); Also, notifying of property changes (or signal emission) would index the array as well: g_object_notify_by_pspec(objectInstance, sObjProperties[PROP_FOO]); In both cases this is doing array indexing without bounds checking. We can use e.g. std::array<GParamSpec*, N_PROPERTIES> in such cases, and reduce the usage of WTF_ALLOW_UNSAFE_BUFFER_USAGE_{BEGIN,END}.
Attachments
Add attachment
proposed patch, testcase, etc.
Adrian Perez
Comment 1
2024-10-17 07:20:18 PDT
While there are possibilities of making the signals/properties mechanism more idiomatic and have better type checking (maybe using EnumTraits), this issue is only about removing unsafe buffer uses.
Adrian Perez
Comment 2
2024-10-17 08:00:41 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/35361
EWS
Comment 3
2024-10-18 07:18:53 PDT
Committed
285400@main
(9d3358a6d868): <
https://commits.webkit.org/285400@main
> Reviewed commits have been landed. Closing PR #35361 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug