From: Danny Al-Gaaf Date: Sat, 22 Mar 2014 21:08:06 +0000 (+0100) Subject: jerasure.c: fix memory leak in error case X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f55106369a4c926c8d7995fbcf4c4f4799bcaa0a;p=jerasure.git 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 (cherry picked from commit 6d8fbc8b818c9f23a538f1586ee055b1dd7a7f2f) --- diff --git a/src/jerasure.c b/src/jerasure.c index 4297653..8237bfc 100644 --- a/src/jerasure.c +++ b/src/jerasure.c @@ -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;