diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 0d50a5b72df..e9225a3d937 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -2016,7 +2016,13 @@ static char *read_file_as_buffer(const int fd, const bool nil_terminate, size_t { struct ByteChunk { ByteChunk *next; - char data[4096 - sizeof(ByteChunk *)]; + /* NOTE(@ideasman42): On GNOME-SHELL-43.3, non powers of two values + * (1023 or 4088 for e.g.) makes `read()` return longer values than are actually read + * (causing uninitialized memory to be used) as well as truncating the end of the buffer. + * The WAYLAND spec doesn't mention buffer-size so this may be a bug in GNOME-SHELL. + * Whatever the case, using a power of two isn't a problem (besides some slop-space waste). + * This works in KDE & WLROOTS based compositors, see: #106040. */ + char data[4096]; }; ByteChunk *chunk_first = nullptr, **chunk_link_p = &chunk_first; bool ok = true;