Commit 6d8fbc8b818c9f23a538f1586ee055b1dd7a7f2f

Authored by Danny Al-Gaaf
1 parent 9e6b3483
Exists in master

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>
Showing 1 changed file with 2 additions and 1 deletions   Show diff stats
src/jerasure.c
... ... @@ -273,9 +273,10 @@ int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int *matrix)
273 273 int *bitmatrix;
274 274 int rowelts, rowindex, colindex, elt, i, j, l, x;
275 275  
276   - bitmatrix = talloc(int, k*m*w*w);
277 276 if (matrix == NULL) { return NULL; }
278 277  
  278 + bitmatrix = talloc(int, k*m*w*w);
  279 +
279 280 rowelts = k * w;
280 281 rowindex = 0;
281 282  
... ...