Skip to content

Commit 9c6d90a

Browse files
committed
[WPEPlatform] WPEClipboard.changed vfunc gets passed a stray null format
https://bugs.webkit.org/show_bug.cgi?id=327420 Reviewed by Patrick Griffis. Use a null-terminated GPtrArray to hold the list of formats passed to the WPEClipboard.changed() virtual function. This way the GPtrArray::len member correctly indicates the number of elements in the array while still being possible to use it as the return value for wpe_clipboard_get_formats(). Using g_ptr_array_new_null_terminated() requires GLib 2.74, the requirement is updated accordingly for the WPE port. * Source/WTF/wtf/Platform.h: * Source/WebKit/WPEPlatform/wpe/WPEClipboard.cpp: (wpe_clipboard_set_content): * Source/WebKit/WPEPlatform/wpe/wayland/WPEClipboardWayland.cpp: (wpeClipboardWaylandChanged): * Source/cmake/OptionsWPE.cmake: Canonical link: https://commits.webkit.org/324164@main
1 parent a6908ef commit 9c6d90a

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎Source/WTF/wtf/Platform.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292

9393
#if USE(GLIB)
9494
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_56
95-
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_70
95+
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_74
9696
#endif
9797

9898
#if PLATFORM(GTK)

‎Source/WebKit/WPEPlatform/wpe/WPEClipboard.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void wpe_clipboard_set_content(WPEClipboard* clipboard, WPEClipboardContent* con
268268

269269
GRefPtr<GPtrArray> formats;
270270
if (content) {
271-
formats = adoptGRef(g_ptr_array_new());
271+
formats = adoptGRef(g_ptr_array_new_null_terminated(3, nullptr, TRUE));
272272
if (content->text) {
273273
g_ptr_array_add(formats.get(), static_cast<gpointer>(const_cast<char*>(g_intern_static_string("text/plain"))));
274274
g_ptr_array_add(formats.get(), static_cast<gpointer>(const_cast<char*>(g_intern_static_string("text/plain;charset=utf-8"))));
@@ -277,7 +277,6 @@ void wpe_clipboard_set_content(WPEClipboard* clipboard, WPEClipboardContent* con
277277
for (const auto* format : content->buffers->keys())
278278
g_ptr_array_add(formats.get(), static_cast<gpointer>(const_cast<char*>(format)));
279279
}
280-
g_ptr_array_add(formats.get(), nullptr);
281280
}
282281

283282
WPE_CLIPBOARD_GET_CLASS(clipboard)->changed(clipboard, formats.get(), TRUE, content);

‎Source/WebKit/WPEPlatform/wpe/wayland/WPEClipboardWayland.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static const struct wl_data_device_listener wlDataDeviceListener = {
128128
priv->offer = offer;
129129
wl_data_offer_add_listener(priv->offer, &wlDataOfferListener, data);
130130

131-
priv->formats = adoptGRef(g_ptr_array_new());
131+
priv->formats = adoptGRef(g_ptr_array_new_null_terminated(3, nullptr, TRUE));
132132
},
133133
// enter
134134
[](void*, wl_data_device*, uint32_t /*serial*/, wl_surface*, wl_fixed_t /*x*/, wl_fixed_t /*y*/, wl_data_offer*) {
@@ -226,7 +226,7 @@ static void wpeClipboardWaylandChanged(WPEClipboard* clipboard, GPtrArray* forma
226226
wl_data_source_add_listener(priv->source, &wlDataSourceListener, clipboard);
227227

228228
if (formats) {
229-
for (const char* format : span(reinterpret_cast<char**>(formats->pdata)))
229+
for (const char* format : span<const char*>(formats))
230230
wl_data_source_offer(priv->source, format);
231231
}
232232

‎Source/cmake/OptionsWPE.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ list(APPEND WEBKIT_UNSAFE_BUFFER_WARNING_FLAGS -Wno-unsafe-buffer-usage-in-forma
1111
set(ENABLE_THREAD_SAFETY_WARNING ON)
1212

1313
# Update Source/WTF/wtf/Platform.h to match required GLib versions.
14-
find_package(GLib 2.70.0 REQUIRED COMPONENTS GioUnix Thread Module)
14+
find_package(GLib 2.74.0 REQUIRED COMPONENTS GioUnix Thread Module)
1515
find_package(HarfBuzz 2.7.4 REQUIRED COMPONENTS ICU)
1616
find_package(ICU 70.1 REQUIRED COMPONENTS data i18n uc)
1717
find_package(JPEG REQUIRED)

0 commit comments

Comments
 (0)