|
|
e5da31 |
From 9d84623c724b9599071fb7f12a189746f7b0ff3f Mon Sep 17 00:00:00 2001
|
|
|
e5da31 |
From: Philip Withnall <pwithnall@endlessos.org>
|
|
|
e5da31 |
Date: Thu, 4 Feb 2021 13:39:25 +0000
|
|
|
e5da31 |
Subject: [PATCH 03/12] gobject: Use g_memdup2() instead of g_memdup() in
|
|
|
e5da31 |
obvious places
|
|
|
e5da31 |
MIME-Version: 1.0
|
|
|
e5da31 |
Content-Type: text/plain; charset=UTF-8
|
|
|
e5da31 |
Content-Transfer-Encoding: 8bit
|
|
|
e5da31 |
|
|
|
e5da31 |
Convert all the call sites which use `g_memdup()`’s length argument
|
|
|
e5da31 |
trivially (for example, by passing a `sizeof()`), so that they use
|
|
|
e5da31 |
`g_memdup2()` instead.
|
|
|
e5da31 |
|
|
|
e5da31 |
In almost all of these cases the use of `g_memdup()` would not have
|
|
|
e5da31 |
caused problems, but it will soon be deprecated, so best port away from
|
|
|
e5da31 |
it.
|
|
|
e5da31 |
|
|
|
e5da31 |
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
|
|
e5da31 |
Helps: #2319
|
|
|
e5da31 |
---
|
|
|
e5da31 |
gobject/gsignal.c | 3 ++-
|
|
|
e5da31 |
gobject/gtype.c | 9 +++++----
|
|
|
e5da31 |
gobject/gtypemodule.c | 3 ++-
|
|
|
e5da31 |
gobject/tests/param.c | 4 +++-
|
|
|
e5da31 |
4 files changed, 12 insertions(+), 7 deletions(-)
|
|
|
e5da31 |
|
|
|
e5da31 |
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
|
|
|
e5da31 |
index b22dfcca8..92555eb60 100644
|
|
|
e5da31 |
--- a/gobject/gsignal.c
|
|
|
e5da31 |
+++ b/gobject/gsignal.c
|
|
|
e5da31 |
@@ -28,6 +28,7 @@
|
|
|
e5da31 |
#include <signal.h>
|
|
|
e5da31 |
|
|
|
e5da31 |
#include "gsignal.h"
|
|
|
e5da31 |
+#include "gstrfuncsprivate.h"
|
|
|
e5da31 |
#include "gtype-private.h"
|
|
|
e5da31 |
#include "gbsearcharray.h"
|
|
|
e5da31 |
#include "gvaluecollector.h"
|
|
|
e5da31 |
@@ -1724,7 +1725,7 @@ g_signal_newv (const gchar *signal_name,
|
|
|
e5da31 |
node->single_va_closure_is_valid = FALSE;
|
|
|
e5da31 |
node->flags = signal_flags & G_SIGNAL_FLAGS_MASK;
|
|
|
e5da31 |
node->n_params = n_params;
|
|
|
e5da31 |
- node->param_types = g_memdup (param_types, sizeof (GType) * n_params);
|
|
|
e5da31 |
+ node->param_types = g_memdup2 (param_types, sizeof (GType) * n_params);
|
|
|
e5da31 |
node->return_type = return_type;
|
|
|
e5da31 |
node->class_closure_bsa = NULL;
|
|
|
e5da31 |
if (accumulator)
|
|
|
e5da31 |
diff --git a/gobject/gtype.c b/gobject/gtype.c
|
|
|
e5da31 |
index 275a8b60b..9e663ce52 100644
|
|
|
e5da31 |
--- a/gobject/gtype.c
|
|
|
e5da31 |
+++ b/gobject/gtype.c
|
|
|
e5da31 |
@@ -33,6 +33,7 @@
|
|
|
e5da31 |
|
|
|
e5da31 |
#include "glib-private.h"
|
|
|
e5da31 |
#include "gconstructor.h"
|
|
|
e5da31 |
+#include "gstrfuncsprivate.h"
|
|
|
e5da31 |
|
|
|
e5da31 |
#ifdef G_OS_WIN32
|
|
|
e5da31 |
#include <windows.h>
|
|
|
e5da31 |
@@ -1471,7 +1472,7 @@ type_add_interface_Wm (TypeNode *node,
|
|
|
e5da31 |
iholder->next = iface_node_get_holders_L (iface);
|
|
|
e5da31 |
iface_node_set_holders_W (iface, iholder);
|
|
|
e5da31 |
iholder->instance_type = NODE_TYPE (node);
|
|
|
e5da31 |
- iholder->info = info ? g_memdup (info, sizeof (*info)) : NULL;
|
|
|
e5da31 |
+ iholder->info = info ? g_memdup2 (info, sizeof (*info)) : NULL;
|
|
|
e5da31 |
iholder->plugin = plugin;
|
|
|
e5da31 |
|
|
|
e5da31 |
/* create an iface entry for this type */
|
|
|
e5da31 |
@@ -1732,7 +1733,7 @@ type_iface_retrieve_holder_info_Wm (TypeNode *iface,
|
|
|
e5da31 |
INVALID_RECURSION ("g_type_plugin_*", iholder->plugin, NODE_NAME (iface));
|
|
|
e5da31 |
|
|
|
e5da31 |
check_interface_info_I (iface, instance_type, &tmp_info);
|
|
|
e5da31 |
- iholder->info = g_memdup (&tmp_info, sizeof (tmp_info));
|
|
|
e5da31 |
+ iholder->info = g_memdup2 (&tmp_info, sizeof (tmp_info));
|
|
|
e5da31 |
}
|
|
|
e5da31 |
|
|
|
e5da31 |
return iholder; /* we don't modify write lock upon returning NULL */
|
|
|
e5da31 |
@@ -2013,10 +2014,10 @@ type_iface_vtable_base_init_Wm (TypeNode *iface,
|
|
|
e5da31 |
IFaceEntry *pentry = type_lookup_iface_entry_L (pnode, iface);
|
|
|
e5da31 |
|
|
|
e5da31 |
if (pentry)
|
|
|
e5da31 |
- vtable = g_memdup (pentry->vtable, iface->data->iface.vtable_size);
|
|
|
e5da31 |
+ vtable = g_memdup2 (pentry->vtable, iface->data->iface.vtable_size);
|
|
|
e5da31 |
}
|
|
|
e5da31 |
if (!vtable)
|
|
|
e5da31 |
- vtable = g_memdup (iface->data->iface.dflt_vtable, iface->data->iface.vtable_size);
|
|
|
e5da31 |
+ vtable = g_memdup2 (iface->data->iface.dflt_vtable, iface->data->iface.vtable_size);
|
|
|
e5da31 |
entry->vtable = vtable;
|
|
|
e5da31 |
vtable->g_type = NODE_TYPE (iface);
|
|
|
e5da31 |
vtable->g_instance_type = NODE_TYPE (node);
|
|
|
e5da31 |
diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c
|
|
|
e5da31 |
index c67f789b1..cf877bc0b 100644
|
|
|
e5da31 |
--- a/gobject/gtypemodule.c
|
|
|
e5da31 |
+++ b/gobject/gtypemodule.c
|
|
|
e5da31 |
@@ -19,6 +19,7 @@
|
|
|
e5da31 |
|
|
|
e5da31 |
#include <stdlib.h>
|
|
|
e5da31 |
|
|
|
e5da31 |
+#include "gstrfuncsprivate.h"
|
|
|
e5da31 |
#include "gtypeplugin.h"
|
|
|
e5da31 |
#include "gtypemodule.h"
|
|
|
e5da31 |
|
|
|
e5da31 |
@@ -436,7 +437,7 @@ g_type_module_register_type (GTypeModule *module,
|
|
|
e5da31 |
module_type_info->loaded = TRUE;
|
|
|
e5da31 |
module_type_info->info = *type_info;
|
|
|
e5da31 |
if (type_info->value_table)
|
|
|
e5da31 |
- module_type_info->info.value_table = g_memdup (type_info->value_table,
|
|
|
e5da31 |
+ module_type_info->info.value_table = g_memdup2 (type_info->value_table,
|
|
|
e5da31 |
sizeof (GTypeValueTable));
|
|
|
e5da31 |
|
|
|
e5da31 |
return module_type_info->type;
|
|
|
e5da31 |
diff --git a/gobject/tests/param.c b/gobject/tests/param.c
|
|
|
e5da31 |
index 758289bf8..971cff162 100644
|
|
|
e5da31 |
--- a/gobject/tests/param.c
|
|
|
e5da31 |
+++ b/gobject/tests/param.c
|
|
|
e5da31 |
@@ -2,6 +2,8 @@
|
|
|
e5da31 |
#include <glib-object.h>
|
|
|
e5da31 |
#include <stdlib.h>
|
|
|
e5da31 |
|
|
|
e5da31 |
+#include "gstrfuncsprivate.h"
|
|
|
e5da31 |
+
|
|
|
e5da31 |
static void
|
|
|
e5da31 |
test_param_value (void)
|
|
|
e5da31 |
{
|
|
|
e5da31 |
@@ -851,7 +853,7 @@ main (int argc, char *argv[])
|
|
|
e5da31 |
test_path = g_strdup_printf ("/param/implement/subprocess/%d-%d-%d-%d",
|
|
|
e5da31 |
data.change_this_flag, data.change_this_type,
|
|
|
e5da31 |
data.use_this_flag, data.use_this_type);
|
|
|
e5da31 |
- test_data = g_memdup (&data, sizeof (TestParamImplementData));
|
|
|
e5da31 |
+ test_data = g_memdup2 (&data, sizeof (TestParamImplementData));
|
|
|
e5da31 |
g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free);
|
|
|
e5da31 |
g_free (test_path);
|
|
|
e5da31 |
}
|
|
|
e5da31 |
--
|
|
|
e5da31 |
2.31.1
|
|
|
e5da31 |
|