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>
#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

View File

@ -13,6 +13,8 @@
#include "gdkbroadway-server.h"
#include "gdkprivate-broadway.h"
#include "gdk-private.h"
#include <gdk/gdktextureprivate.h>
#include <glib.h>
@ -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);

View File

@ -41,6 +41,7 @@
#include "gdksurfaceprivate.h"
#include "gdktextureprivate.h"
#include "gdktoplevelprivate.h"
#include "gdk-private.h"
#include <graphene.h>
#include <stdlib.h>
@ -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;
}