[glib/wip/2-58-cve-2021-27219: 3/8] ghash: Use g_memdup2() instead of g_memdup()




commit 3e0bb3bf0f4b6ac43ab8aea531d804748b9b19a3
Author: Simon McVittie <smcv collabora com>
Date:   Thu Mar 18 10:31:00 2021 +0000

    ghash: Use g_memdup2() instead of g_memdup()
    
    Backport of part of commit 0736b7c1e7cf4232c5d7eb2b0fbfe9be81bd3baa
    to the simpler structure of the GHashTable code in glib-2-58.
    
    Helps: #2319
    Signed-off-by: Simon McVittie <smcv collabora com>

 glib/ghash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/glib/ghash.c b/glib/ghash.c
index 433004cf8..e36a7a8ed 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -34,6 +34,7 @@
 
 #include "glib-private.h"
 #include "gstrfuncs.h"
+#include "gstrfuncsprivate.h"
 #include "gatomic.h"
 #include "gtestutils.h"
 #include "gslice.h"
@@ -967,7 +968,7 @@ g_hash_table_insert_node (GHashTable *hash_table,
    * split the table.
    */
   if (G_UNLIKELY (hash_table->keys == hash_table->values && hash_table->keys[node_index] != new_value))
-    hash_table->values = g_memdup (hash_table->keys, sizeof (gpointer) * hash_table->size);
+    hash_table->values = g_memdup2 (hash_table->keys, sizeof (gpointer) * hash_table->size);
 
   /* Step 3: Actually do the write */
   hash_table->values[node_index] = new_value;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]