broadway: Move from g_memdup() to g_memdup2()

The g_memdup() function is replaced by a safer version in newer versions
of GLib.
This commit is contained in:
Emmanuele Bassi 2021-02-04 19:09:56 +00:00
parent 965e74f902
commit 504b5bbd1b
3 changed files with 12 additions and 5 deletions

View File

@ -36,6 +36,10 @@
#include <string.h> #include <string.h>
#endif #endif
#if !GLIB_CHECK_VERSION (2, 67, 3)
# define g_memdup2(mem,size) g_memdup((mem), (size))
#endif
typedef struct { typedef struct {
int id; int id;
guint32 tag; guint32 tag;
@ -605,7 +609,7 @@ update_future_pointer_info (BroadwayServer *server, BroadwayInputPointerMsg *dat
static void static void
queue_input_message (BroadwayServer *server, BroadwayInputMsg *msg) 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 static void

View File

@ -13,6 +13,8 @@
#include "gdkbroadway-server.h" #include "gdkbroadway-server.h"
#include "gdkprivate-broadway.h" #include "gdkprivate-broadway.h"
#include "gdk-private.h"
#include <gdk/gdktextureprivate.h> #include <gdk/gdktextureprivate.h>
#include <glib.h> #include <glib.h>
@ -233,7 +235,7 @@ static void
parse_all_input (GdkBroadwayServer *server) parse_all_input (GdkBroadwayServer *server)
{ {
guint8 *p, *end; guint8 *p, *end;
guint32 size; size_t size;
BroadwayReply *reply; BroadwayReply *reply;
p = server->recv_buffer; p = server->recv_buffer;
@ -245,7 +247,7 @@ parse_all_input (GdkBroadwayServer *server)
if (p + size > end) if (p + size > end)
break; break;
reply = g_memdup (p, size); reply = g_memdup2 (p, size);
p += size; p += size;
server->incoming = g_list_append (server->incoming, reply); server->incoming = g_list_append (server->incoming, reply);

View File

@ -41,6 +41,7 @@
#include "gdksurfaceprivate.h" #include "gdksurfaceprivate.h"
#include "gdktextureprivate.h" #include "gdktextureprivate.h"
#include "gdktoplevelprivate.h" #include "gdktoplevelprivate.h"
#include "gdk-private.h"
#include <graphene.h> #include <graphene.h>
#include <stdlib.h> #include <stdlib.h>
@ -1025,7 +1026,7 @@ _gdk_broadway_moveresize_handle_event (GdkDisplay *display,
*mv_resize->moveresize_pending_event = *event; *mv_resize->moveresize_pending_event = *event;
else else
mv_resize->moveresize_pending_event = mv_resize->moveresize_pending_event =
g_memdup (event, sizeof (BroadwayInputMsg)); g_memdup2 (event, sizeof (BroadwayInputMsg));
break; break;
} }
@ -1043,7 +1044,7 @@ _gdk_broadway_moveresize_handle_event (GdkDisplay *display,
*mv_resize->moveresize_pending_event = *event; *mv_resize->moveresize_pending_event = *event;
else else
mv_resize->moveresize_pending_event = mv_resize->moveresize_pending_event =
g_memdup (event, sizeof (BroadwayInputMsg)); g_memdup2 (event, sizeof (BroadwayInputMsg));
break; break;
} }