From 6d8fbc8b818c9f23a538f1586ee055b1dd7a7f2f Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Sat, 22 Mar 2014 22:08:06 +0100 Subject: [PATCH] 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 --- src/jerasure.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jerasure.c b/src/jerasure.c index bb577af..d2af918 100644 --- a/src/jerasure.c +++ b/src/jerasure.c @@ -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; -- 2.47.3