Commit fa1ea7133b5932967bc8dabb763a84fb87d3e54a

Authored by Danny Al-Gaaf
Committed by Loic Dachary
1 parent ff703215
Exists in v2

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