[gegl] gegl-scratch: fix potential segfault when freeing context-less block
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl-scratch: fix potential segfault when freeing context-less block
- Date: Mon, 7 Jan 2019 18:42:45 +0000 (UTC)
commit 5ef66e7c2f33d5a9336a4371cbf0e0acb02700a7
Author: Ell <ell_se yahoo com>
Date: Mon Jan 7 13:38:35 2019 -0500
gegl-scratch: fix potential segfault when freeing context-less block
Fix a potential segfault when freeing a context-less block on a
thread that doesn't have a scratch context yet.
gegl/buffer/gegl-scratch.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/gegl/buffer/gegl-scratch.c b/gegl/buffer/gegl-scratch.c
index f3225b487..7b41324c2 100644
--- a/gegl/buffer/gegl-scratch.c
+++ b/gegl/buffer/gegl-scratch.c
@@ -79,9 +79,10 @@ static void gegl_scratch_block_free (GeglScratchBlock *block
/* local variables */
-GPrivate gegl_scratch_context =
- G_PRIVATE_INIT ((GDestroyNotify) gegl_scratch_context_free);
-static volatile guintptr gegl_scratch_total;
+static GPrivate gegl_scratch_context = G_PRIVATE_INIT (
+ (GDestroyNotify) gegl_scratch_context_free);
+static const GeglScratchContext void_context;
+static volatile guintptr gegl_scratch_total;
/* private functions */
@@ -153,7 +154,8 @@ gegl_scratch_alloc (gsize size)
if (G_UNLIKELY (size > GEGL_SCRATCH_MAX_BLOCK_SIZE))
{
- block = gegl_scratch_block_new (NULL, size);
+ block = gegl_scratch_block_new ((GeglScratchContext *) &void_context,
+ size);
return block->data;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]