Skip to content

Commit

Permalink
Merge pull request #3 from tcullum-gpsw/fix-memory-leaks
Browse files Browse the repository at this point in the history
fixed 3 potential memory leaks when function PrepareCodebooks
  • Loading branch information
dnewman-gpsw committed Jun 29, 2018
2 parents af95987 + 0ad3f96 commit 77bcd76
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/lib/vc5_encoder/codebooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ CODEC_ERROR PrepareCodebooks(const gpr_allocator *allocator, ENCODER_CODESET *cs
mags_table_size = mags_table_length * sizeof(VLE) + sizeof(MAGS_TABLE);
mags_table = allocator->Alloc(mags_table_size);
if (mags_table == NULL) {
allocator->Free( (void *)runs_table);
return CODEC_ERROR_OUTOFMEMORY;
}

Expand All @@ -92,6 +93,7 @@ CODEC_ERROR PrepareCodebooks(const gpr_allocator *allocator, ENCODER_CODESET *cs
error = ComputeRunLengthCodeTable(allocator,
old_codes, old_length, new_codes, new_length);
if (error != CODEC_ERROR_OKAY) {
allocator->Free( (void *)runs_table);
return error;
}

Expand All @@ -101,6 +103,7 @@ CODEC_ERROR PrepareCodebooks(const gpr_allocator *allocator, ENCODER_CODESET *cs

error = FillMagnitudeEncodingTable(cs->codebook, mags_table_entries, mags_table_length, cs->flags);
if (error != CODEC_ERROR_OKAY) {
allocator->Free( (void *)runs_table);
return error;
}

Expand Down

0 comments on commit 77bcd76

Please sign in to comment.