[glib: 6/7] gboxed: Fix two potential NULL pointer dereferences



commit 8f52d2cb022a2bce6ade375db45f162123552ace
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Sep 5 14:16:11 2019 +0100

    gboxed: Fix two potential NULL pointer dereferences
    
    I don’t think these could be hit in practice due to the guarantees of
    the type system, but the static analyser doesn’t know that — so make the
    assertions clearer to shut it up.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: #1767

 gobject/gboxed.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index 4404de3d6..87cc5d2c2 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -346,8 +346,7 @@ g_boxed_copy (GType         boxed_type,
   g_return_val_if_fail (src_boxed != NULL, NULL);
 
   value_table = g_type_value_table_peek (boxed_type);
-  if (!value_table)
-    g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL);
+  g_assert (value_table != NULL);
 
   /* check if our proxying implementation is used, we can short-cut here */
   if (value_table->value_copy == boxed_proxy_value_copy)
@@ -404,8 +403,7 @@ g_boxed_free (GType    boxed_type,
   g_return_if_fail (boxed != NULL);
 
   value_table = g_type_value_table_peek (boxed_type);
-  if (!value_table)
-    g_return_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type));
+  g_assert (value_table != NULL);
 
   /* check if our proxying implementation is used, we can short-cut here */
   if (value_table->value_free == boxed_proxy_value_free)


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