[gegl] buffer: don't abort when gegl_free()ing a NULL pointer



commit a1707af441720c818624278a2c0ced0e64c142f9
Author: Ell <ell_se yahoo com>
Date:   Sun Jan 6 05:52:21 2019 -0500

    buffer: don't abort when gegl_free()ing a NULL pointer
    
    ... instead, do nothing.

 gegl/buffer/gegl-memory.c | 4 +++-
 gegl/buffer/gegl-memory.h | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gegl/buffer/gegl-memory.c b/gegl/buffer/gegl-memory.c
index 56679dc70..3d2758ebf 100644
--- a/gegl/buffer/gegl-memory.c
+++ b/gegl/buffer/gegl-memory.c
@@ -60,7 +60,9 @@ gegl_calloc (gsize size,
 void
 gegl_free (gpointer buf)
 {
-  g_assert (buf);
+  if (! buf)
+    return;
+
   g_free ((gchar*)buf - *((guint8*)buf -1));
 }
 
diff --git a/gegl/buffer/gegl-memory.h b/gegl/buffer/gegl-memory.h
index 44d3774c8..881ce2dbc 100644
--- a/gegl/buffer/gegl-memory.h
+++ b/gegl/buffer/gegl-memory.h
@@ -39,7 +39,7 @@ gpointer   gegl_malloc         (gsize         n_bytes) G_GNUC_MALLOC;
  * gegl_free: (skip)
  * @mem: the memory to free.
  *
- * Frees the memory pointed to by @mem, if @mem is NULL it will warn and abort.
+ * Frees the memory pointed to by @mem. If @mem is NULL, does nothing.
  */
 void       gegl_free           (gpointer      mem);
 


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