summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>2014-03-22 22:08:06 +0100
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>2014-04-22 20:36:32 +0200
commit6d8fbc8b818c9f23a538f1586ee055b1dd7a7f2f (patch)
treed57679d1ff2ee50b9cc5fdbeaca24183d419add2
parent9e6b3483a36a79d177a2e45d5775f5555827761b (diff)
downloadjerasure-6d8fbc8b818c9f23a538f1586ee055b1dd7a7f2f.tar.gz
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>
-rw-r--r--src/jerasure.c3
1 files changed, 2 insertions, 1 deletions
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;