[gegl] Issue #177 - GIMP crashes when cache size is set too high



commit 895bcd0624b82fae7416c50b309f66b9d9dc54f3
Author: Ell <ell_se yahoo com>
Date:   Fri Jul 19 19:30:22 2019 +0300

    Issue #177 - GIMP crashes when cache size is set too high
    
    Use gegl_try_malloc(), instead of gegl_malloc(), when allocating a
    new block, to avoid aborting on allocation failure; when this
    happens, we simply fall back to allocating individual tiles.
    
    Block allocation can most notably fail when the tile-cache size is
    set much higher than the actual memory size, since blocks are sized
    at ~1% if the cache size.

 gegl/buffer/gegl-tile-alloc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gegl/buffer/gegl-tile-alloc.c b/gegl/buffer/gegl-tile-alloc.c
index bb1751161..38c8e824e 100644
--- a/gegl/buffer/gegl-tile-alloc.c
+++ b/gegl/buffer/gegl-tile-alloc.c
@@ -153,7 +153,10 @@ gegl_tile_block_new (GeglTileBlock * volatile *block_ptr,
   if (block_size <= buffer_size)
     return NULL;
 
-  block = gegl_malloc (GEGL_TILE_BLOCK_BUFFER_OFFSET + block_size);
+  block = gegl_try_malloc (GEGL_TILE_BLOCK_BUFFER_OFFSET + block_size);
+
+  if (! block)
+    return NULL;
 
   block->block_ptr   = block_ptr;
   block->size        = GEGL_TILE_BLOCK_BUFFER_OFFSET + block_size;


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