From 504b5bbd1b056613b6ba8ec3462a9498b8745caa Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 4 Feb 2021 19:09:56 +0000 Subject: [PATCH] broadway: Move from g_memdup() to g_memdup2() The g_memdup() function is replaced by a safer version in newer versions of GLib. --- gdk/broadway/broadway-server.c | 6 +++++- gdk/broadway/gdkbroadway-server.c | 6 ++++-- gdk/broadway/gdksurface-broadway.c | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gdk/broadway/broadway-server.c b/gdk/broadway/broadway-server.c index a82b3e82df..b54ae55149 100644 --- a/gdk/broadway/broadway-server.c +++ b/gdk/broadway/broadway-server.c @@ -36,6 +36,10 @@ #include #endif +#if !GLIB_CHECK_VERSION (2, 67, 3) +# define g_memdup2(mem,size) g_memdup((mem), (size)) +#endif + typedef struct { int id; guint32 tag; @@ -605,7 +609,7 @@ update_future_pointer_info (BroadwayServer *server, BroadwayInputPointerMsg *dat static void queue_input_message (BroadwayServer *server, BroadwayInputMsg *msg) { - server->input_messages = g_list_append (server->input_messages, g_memdup (msg, sizeof (BroadwayInputMsg))); + server->input_messages = g_list_append (server->input_messages, g_memdup2 (msg, sizeof (BroadwayInputMsg))); } static void diff --git a/gdk/broadway/gdkbroadway-server.c b/gdk/broadway/gdkbroadway-server.c index 1aeb1649e9..02b6f93183 100644 --- a/gdk/broadway/gdkbroadway-server.c +++ b/gdk/broadway/gdkbroadway-server.c @@ -13,6 +13,8 @@ #include "gdkbroadway-server.h" #include "gdkprivate-broadway.h" +#include "gdk-private.h" + #include #include @@ -233,7 +235,7 @@ static void parse_all_input (GdkBroadwayServer *server) { guint8 *p, *end; - guint32 size; + size_t size; BroadwayReply *reply; p = server->recv_buffer; @@ -245,7 +247,7 @@ parse_all_input (GdkBroadwayServer *server) if (p + size > end) break; - reply = g_memdup (p, size); + reply = g_memdup2 (p, size); p += size; server->incoming = g_list_append (server->incoming, reply); diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index 0d90e270a6..36930072c4 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -41,6 +41,7 @@ #include "gdksurfaceprivate.h" #include "gdktextureprivate.h" #include "gdktoplevelprivate.h" +#include "gdk-private.h" #include #include @@ -1025,7 +1026,7 @@ _gdk_broadway_moveresize_handle_event (GdkDisplay *display, *mv_resize->moveresize_pending_event = *event; else mv_resize->moveresize_pending_event = - g_memdup (event, sizeof (BroadwayInputMsg)); + g_memdup2 (event, sizeof (BroadwayInputMsg)); break; } @@ -1043,7 +1044,7 @@ _gdk_broadway_moveresize_handle_event (GdkDisplay *display, *mv_resize->moveresize_pending_event = *event; else mv_resize->moveresize_pending_event = - g_memdup (event, sizeof (BroadwayInputMsg)); + g_memdup2 (event, sizeof (BroadwayInputMsg)); break; }