Commit b14af86424e3cb8c89c0f2fd2b856580e446fba4

Authored by Danny Al-Gaaf
1 parent 4b6c76c6
Exists in master

jerasure.c: free memory before return in error case

Fix for Coverity issue from Ceph project:

CID 1093211 (#1 of 1): Resource leak (RESOURCE_LEAK)
 20. leaked_storage: Variable "ind_to_row" going out of scope leaks
 the storage it points to.

CID 1093212 (#1 of 1): Resource leak (RESOURCE_LEAK)
 20. leaked_storage: Variable "row_ids" 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 5 additions and 1 deletions   Show diff stats
src/jerasure.c
... ... @@ -838,7 +838,11 @@ static int **jerasure_generate_decoding_schedule(int k, int m, int w, int *bitma
838 838 row_ids = talloc(int, k+m);
839 839 ind_to_row = talloc(int, k+m);
840 840  
841   - if (set_up_ids_for_scheduled_decoding(k, m, erasures, row_ids, ind_to_row) < 0) return NULL;
  841 + if (set_up_ids_for_scheduled_decoding(k, m, erasures, row_ids, ind_to_row) < 0) {
  842 + free(row_ids);
  843 + free(ind_to_row);
  844 + return NULL;
  845 + }
842 846  
843 847 /* Now, we're going to create one decoding matrix which is going to
844 848 decode everything with one call. The hope is that the scheduler
... ...