diff --git a/MP42/MP42FormatUtilites.h b/MP42/MP42FormatUtilites.h index 21f319a..a1c9031 100644 --- a/MP42/MP42FormatUtilites.h +++ b/MP42/MP42FormatUtilites.h @@ -19,7 +19,7 @@ extern "C" { int analyze_EAC3(void **context ,uint8_t *frame, uint32_t size); CFDataRef createCookie_EAC3(void *context); - + void free_EAC3_context(void *context); typedef struct MPEG4AudioConfig { int object_type; diff --git a/MP42/MP42FormatUtilites.mm b/MP42/MP42FormatUtilites.mm index eed1bd4..d669329 100644 --- a/MP42/MP42FormatUtilites.mm +++ b/MP42/MP42FormatUtilites.mm @@ -760,6 +760,9 @@ concatenate: if (!info->num_blocks) { // Copy the frame + if (info->frame) { + free(info->frame); + } info->frame = (uint8_t *)malloc(size); if (info->frame == NULL) { return -2; @@ -820,6 +823,7 @@ CFDataRef createCookie_EAC3(void *context) } free(info->frame); + info->frame = NULL; uint8_t *buffer = cookie.GetBuffer(); size_t size = cookie.GetBitPosition() / 8; @@ -829,6 +833,15 @@ CFDataRef createCookie_EAC3(void *context) return cookieData; } +void free_EAC3_context(void *context) +{ + struct eac3_info *info = (struct eac3_info *) context; + free(info->frame); + + info->frame = NULL; + free(context); +} + #pragma mark - MPEG 4 Audio #define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))