avformat/hdsenc: Use av_freep() avoid leaving stale pointers in memory

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 16d763fa45)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2014-12-16 15:01:05 +01:00
parent b85a939633
commit 3a8ad4b878

View File

@@ -145,15 +145,15 @@ static void hds_free(AVFormatContext *s)
if (os->ctx && os->ctx_inited) if (os->ctx && os->ctx_inited)
av_write_trailer(os->ctx); av_write_trailer(os->ctx);
if (os->ctx && os->ctx->pb) if (os->ctx && os->ctx->pb)
av_free(os->ctx->pb); av_freep(&os->ctx->pb);
if (os->ctx) if (os->ctx)
avformat_free_context(os->ctx); avformat_free_context(os->ctx);
av_free(os->metadata); av_freep(&os->metadata);
for (j = 0; j < os->nb_extra_packets; j++) for (j = 0; j < os->nb_extra_packets; j++)
av_free(os->extra_packets[j]); av_freep(&os->extra_packets[j]);
for (j = 0; j < os->nb_fragments; j++) for (j = 0; j < os->nb_fragments; j++)
av_free(os->fragments[j]); av_freep(&os->fragments[j]);
av_free(os->fragments); av_freep(&os->fragments);
} }
av_freep(&c->streams); av_freep(&c->streams);
} }
@@ -499,7 +499,7 @@ static int hds_flush(AVFormatContext *s, OutputStream *os, int final,
if (remove > 0) { if (remove > 0) {
for (i = 0; i < remove; i++) { for (i = 0; i < remove; i++) {
unlink(os->fragments[i]->file); unlink(os->fragments[i]->file);
av_free(os->fragments[i]); av_freep(&os->fragments[i]);
} }
os->nb_fragments -= remove; os->nb_fragments -= remove;
memmove(os->fragments, os->fragments + remove, memmove(os->fragments, os->fragments + remove,