[haiku-commits] haiku: hrev43707 - src/add-ons/opengl/mesa_software_renderer

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 1 Feb 2012 21:05:54 +0100 (CET)

hrev43707 adds 1 changeset to branch 'master'
old head: f7167131ad47798d1fa6d5d00277282185f7514d
new head: ef34f28b38003a2c3cc8d75f5bd014bb48fe85dc

----------------------------------------------------------------------------

ef34f28: opengl add-on: Fix potential memory leaks. CID 2777
  
  * Free GL FrameBuffer which could of resulted in
    memory leaks
  * Add better malloc/calloc failure tracing.

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev43707
Commit:      ef34f28b38003a2c3cc8d75f5bd014bb48fe85dc
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ef34f28
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Wed Feb  1 14:13:20 2012 UTC

----------------------------------------------------------------------------

1 files changed, 13 insertions(+), 1 deletions(-)
.../MesaSoftwareRenderer.cpp                       |   14 +++++++++++++-

----------------------------------------------------------------------------

diff --git a/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp 
b/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp
index 6fb7d8f..6cc414e 100644
--- a/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp
+++ b/src/add-ons/opengl/mesa_software_renderer/MesaSoftwareRenderer.cpp
@@ -285,22 +285,33 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, 
ulong options,
        // create core framebuffer
        fFrameBuffer = (struct msr_framebuffer*)calloc(1,
                sizeof(*fFrameBuffer));
+       if (fFrameBuffer == NULL) {
+               ERROR("%s: Unable to calloc GL FrameBuffer!\n", __func__);
+               _mesa_destroy_visual(fVisual);
+               return;
+       }
        _mesa_initialize_window_framebuffer(&fFrameBuffer->base, fVisual);
 
        // Setup front render buffer
        fFrontRenderBuffer = _NewRenderBuffer(true);
        if (fFrontRenderBuffer == NULL) {
+               ERROR("%s: FrontRenderBuffer is requested but unallocated!\n",
+                       __func__);
                _mesa_destroy_visual(fVisual);
+               free(fFrameBuffer);
                return;
        }
        _mesa_add_renderbuffer(&fFrameBuffer->base, BUFFER_FRONT_LEFT,
                &fFrontRenderBuffer->base);
 
-       // Setup back render buffer (if needed)
+       // Setup back render buffer (if requested)
        if (fVisual->doubleBufferMode) {
                fBackRenderBuffer = _NewRenderBuffer(false);
                if (fBackRenderBuffer == NULL) {
+                       ERROR("%s: BackRenderBuffer is requested but 
unallocated!\n",
+                               __func__);
                        _mesa_destroy_visual(fVisual);
+                       free(fFrameBuffer);
                        return;
                }
                _mesa_add_renderbuffer(&fFrameBuffer->base, BUFFER_BACK_LEFT,
@@ -346,6 +357,7 @@ MesaSoftwareRenderer::~MesaSoftwareRenderer()
        _mesa_destroy_context(fContext);
 
        free(fInfo);
+       free(fFrameBuffer);
 
        delete fBitmap;
 }


Other related posts:

  • » [haiku-commits] haiku: hrev43707 - src/add-ons/opengl/mesa_software_renderer - kallisti5