[vlc-commits] opengl: renderer: refactor error path

Alexandre Janniaux git at videolan.org
Tue Jul 14 20:16:48 CEST 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Thu Jul  9 20:09:39 2020 +0200| [e53471c5276e30bac057c30bf9134874ef8a70a1] | committer: Alexandre Janniaux

opengl: renderer: refactor error path

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e53471c5276e30bac057c30bf9134874ef8a70a1
---

 modules/video_output/opengl/renderer.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index 4563f88043..1bdcdeea30 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -526,22 +526,21 @@ static int BuildCube(float padW, float padH,
     *nbVertices = 4 * 6;
     *nbIndices = 6 * 6;
 
+    *vertexCoord = NULL;
+    *textureCoord = NULL;
+    *indices = NULL;
+
     *vertexCoord = vlc_alloc(*nbVertices * 3, sizeof(GLfloat));
     if (*vertexCoord == NULL)
-        return VLC_ENOMEM;
+        goto error;
+
     *textureCoord = vlc_alloc(*nbVertices * 2, sizeof(GLfloat));
     if (*textureCoord == NULL)
-    {
-        free(*vertexCoord);
-        return VLC_ENOMEM;
-    }
+        goto error;
+
     *indices = vlc_alloc(*nbIndices, sizeof(GLushort));
     if (*indices == NULL)
-    {
-        free(*textureCoord);
-        free(*vertexCoord);
-        return VLC_ENOMEM;
-    }
+        goto error;
 
 #define CUBEFACE(swap, value) \
     swap(value, -1.f,  1.f), \
@@ -619,6 +618,11 @@ static int BuildCube(float padW, float padH,
     memcpy(*indices, ind, *nbIndices * sizeof(GLushort));
 
     return VLC_SUCCESS;
+
+error:
+    free(*vertexCoord);
+    free(*textureCoord);
+    return VLC_ENOMEM;
 }
 
 static int BuildRectangle(GLfloat **vertexCoord, GLfloat **textureCoord, unsigned *nbVertices,



More information about the vlc-commits mailing list