From: Andre Noll Date: Sat, 14 Aug 2021 20:46:50 +0000 (+0200) Subject: mp4: Free the membuffer in membuffer_detach(). X-Git-Tag: v0.7.1~7^2~70 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=293984db989fcb4e9e03f931bea73606f7a66ffb;p=paraslash.git mp4: Free the membuffer in membuffer_detach(). Each call to this function is followed by a call to membuffer_free(), which frees the membuffer but not the data buffer because that was set to NULL. It is simpler to free the membuffer directly in membuffer_detach(). --- diff --git a/mp4.c b/mp4.c index bdbd3221..76cc6737 100644 --- a/mp4.c +++ b/mp4.c @@ -1227,8 +1227,7 @@ static void *membuffer_detach(struct membuffer *buf) if (buf->error) return 0; ret = para_realloc(buf->data, buf->written); - buf->data = 0; - buf->error = 1; + free(buf); return ret; } @@ -1274,8 +1273,6 @@ static uint32_t create_ilst(const struct mp4_metadata *meta, void **out_buffer, *out_size = membuffer_get_size(buf); *out_buffer = membuffer_detach(buf); - membuffer_free(buf); - return 1; } @@ -1332,7 +1329,6 @@ static uint32_t create_meta(const struct mp4_metadata *meta, void **out_buffer, *out_size = membuffer_get_size(buf); *out_buffer = membuffer_detach(buf); - membuffer_free(buf); return 1; } @@ -1354,7 +1350,6 @@ uint32_t * out_size) *out_size = membuffer_get_size(buf); *out_buffer = membuffer_detach(buf); - membuffer_free(buf); return 1; } @@ -1396,9 +1391,7 @@ static void *modify_moov(struct mp4 *f, uint32_t *out_size) free(new_udta_buffer); *out_size = membuffer_get_size(buf); - out_buffer = membuffer_detach(buf); - membuffer_free(buf); - return out_buffer; + return membuffer_detach(buf); } udta_offset = get_position(f); udta_size = read_int32(f); @@ -1430,9 +1423,7 @@ static void *modify_moov(struct mp4 *f, uint32_t *out_size) free(new_meta_buffer); *out_size = membuffer_get_size(buf); - out_buffer = membuffer_detach(buf); - membuffer_free(buf); - return out_buffer; + return membuffer_detach(buf); } meta_offset = get_position(f); meta_size = read_int32(f);