jerasure.c: fix memory leak in error case

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>
master
Danny Al-Gaaf 2014-03-22 22:08:06 +01:00
parent 9e6b3483a3
commit 6d8fbc8b81
1 changed files with 2 additions and 1 deletions

View 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;