]> 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)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 22 Apr 2014 18:36:32 +0000 (20:36 +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>
src/jerasure.c

index bb577af0f38af85e34d11f91b456039ef2894c3c..d2af91889b2f8df20c705b753a0bcd57f16de54e 100644 (file)
@@ -273,9 +273,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;