[webkit-changes] [WebKit/WebKit] 659001: [GTK][WPE] Remove WTF_ALLOW_UNSAFE_BUFFER_USAGE_{B...

Adrian Perez noreply at github.com
Thu Oct 31 05:55:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6590010e1ff81a61395344c17882942c56ceea78
      https://github.com/WebKit/WebKit/commit/6590010e1ff81a61395344c17882942c56ceea78
  Author: Adrian Perez de Castro <aperez at igalia.com>
  Date:   2024-10-31 (Thu, 31 Oct 2024)

  Changed paths:
    M Source/WTF/wtf/PlatformGTK.cmake
    M Source/WTF/wtf/PlatformWPE.cmake
    A Source/WTF/wtf/glib/GSpanExtras.cpp
    M Source/WTF/wtf/glib/GSpanExtras.h
    M Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp

  Log Message:
  -----------
  [GTK][WPE] Remove WTF_ALLOW_UNSAFE_BUFFER_USAGE_{BEGIN,END} in WebKitSettings.cpp
https://bugs.webkit.org/show_bug.cgi?id=282308

Reviewed by Michael Catanzaro.

Introduce helpers for GLib functions which return heap-allocated
arrays, which wrap those into a GMallocSpan (same as MallocSpan,
with GMalloc as allocator by default) that takes care of freeing
memory automatically. Then use the new utility functions to remove
WTF_ALLOW_UNSAFE_BUFFER_USAGE_{BEGIN,END} in WebKitSettings.cpp.

* Source/WTF/wtf/PlatformGTK.cmake: List GSpanExtras.cpp for building.
* Source/WTF/wtf/PlatformWPE.cmake: Ditto.
* Source/WTF/wtf/glib/GSpanExtras.cpp: Added. Includes new functions
WTF::gKeyFileGetKeys() and WTF::gObjectClassGetProperties(), which wrap
the corresponding GLib functions and return a GMallocSpan, easing their
usage at call sites.
(WTF::gKeyFileGetKeys): Added.
(WTF::gObjectClassGetProperties): Added.
* Source/WTF/wtf/glib/GSpanExtras.h: Define GMalloc which implements
memory operations calling GLib functions while allowing per-type
overides, to be used with MallocSpan. A convenience template alias,
GMallocSpan is also defined, which takes care of picking the
corresponding GMalloc<T> specialization.
(WTF::GMalloc::malloc): Added.
(WTF::GMalloc::tryMalloc): Added.
(WTF::GMalloc::zeroedMalloc): Added.
(WTF::GMalloc::tryZeroedMalloc): Added.
(WTF::GMalloc::realloc): Added.
(WTF::GMalloc::tryRealloc): Added.
(WTF::GMalloc::free): Added.
(WTF::GMalloc::nextCapacity): Added.
(WTF::GMallocStrv::free): Added.
(WTF::adoptGMallocSpan): Convenience template function that forwards to
adoptMallocSpan() picking GMalloc as the allocator by default.
* Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp:
(webkit_settings_apply_from_key_file): Use the new helper functions.

Canonical link: https://commits.webkit.org/285949@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list