[cogl] framebuffer: check we have a draw/read_buffer before freeing



commit 89e46a472ffcb48a78ba5ab0ee77812299c9275f
Author: Robert Bragg <robert linux intel com>
Date:   Wed May 11 14:11:31 2011 +0100

    framebuffer: check we have a draw/read_buffer before freeing
    
    When freeing a framebuffer stack it's possible to have entries with NULL
    draw or read buffers so we should check that before calling
    cogl_onscreen/offscreen_free. This fixes a crash with the wayland
    backend when running conformance tests such as cogl-test-object which
    never push a framebuffer.

 cogl/cogl-framebuffer.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 73cce73..cfdb265 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1102,15 +1102,21 @@ _cogl_free_framebuffer_stack (GSList *stack)
     {
       CoglFramebufferStackEntry *entry = l->data;
 
-      if (entry->draw_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
-        _cogl_offscreen_free (COGL_OFFSCREEN (entry->draw_buffer));
-      else
-        _cogl_onscreen_free (COGL_ONSCREEN (entry->draw_buffer));
+      if (entry->draw_buffer)
+        {
+          if (entry->draw_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
+            _cogl_offscreen_free (COGL_OFFSCREEN (entry->draw_buffer));
+          else
+            _cogl_onscreen_free (COGL_ONSCREEN (entry->draw_buffer));
+        }
 
-      if (entry->read_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
-        _cogl_offscreen_free (COGL_OFFSCREEN (entry->read_buffer));
-      else
-        _cogl_onscreen_free (COGL_ONSCREEN (entry->read_buffer));
+      if (entry->read_buffer)
+        {
+          if (entry->read_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
+            _cogl_offscreen_free (COGL_OFFSCREEN (entry->read_buffer));
+          else
+            _cogl_onscreen_free (COGL_ONSCREEN (entry->read_buffer));
+        }
 
       g_slice_free (CoglFramebufferStackEntry, entry);
     }



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