]> git-server-git.apps.pok.os.sepia.ceph.com Git - jerasure.git/commitdiff
jerasure.c: fix memory leak in error case
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Sat, 22 Mar 2014 21:08:06 +0000 (22:08 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 10 Apr 2017 09:15:11 +0000 (11:15 +0200)
Check matrix for NULL before call talloc().

CID 1093213 (#1 of 1): Resource leak (RESOURCE_LEAK)
 4. leaked_storage: Variable "bitmatrix" going out of scope
 leaks the storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
(cherry picked from commit 6d8fbc8b818c9f23a538f1586ee055b1dd7a7f2f)

src/jerasure.c

index 429765308c24e42b5fb0a2f7655baee38558add4..8237bfc1bb0324780482c944023813cfca4acc85 100644 (file)
@@ -274,9 +274,10 @@ int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int *matrix)
   int *bitmatrix;
   int rowelts, rowindex, colindex, elt, i, j, l, x;
 
-  bitmatrix = talloc(int, k*m*w*w);
   if (matrix == NULL) { return NULL; }
 
+  bitmatrix = talloc(int, k*m*w*w);
+
   rowelts = k * w;
   rowindex = 0;