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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/101/head
Michael Niedermayer 10 years ago
parent 383c6a3a07
commit 6e70e4aca5
  1. 8
      libavformat/matroskadec.c

@ -1080,7 +1080,7 @@ static void ebml_free(EbmlSyntax *syntax, void *data)
for (j = 0; j < list->nb_elem; for (j = 0; j < list->nb_elem;
j++, ptr += syntax[i].list_elem_size) j++, ptr += syntax[i].list_elem_size)
ebml_free(syntax[i].def.n, ptr); ebml_free(syntax[i].def.n, ptr);
av_free(list->elem); av_freep(&list->elem);
} else } else
ebml_free(syntax[i].def.n, data_off); ebml_free(syntax[i].def.n, data_off);
default: default:
@ -2137,7 +2137,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
{ {
if (matroska->num_packets > 0) { if (matroska->num_packets > 0) {
memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); memcpy(pkt, matroska->packets[0], sizeof(AVPacket));
av_free(matroska->packets[0]); av_freep(&matroska->packets[0]);
if (matroska->num_packets > 1) { if (matroska->num_packets > 1) {
void *newpackets; void *newpackets;
memmove(&matroska->packets[0], &matroska->packets[1], memmove(&matroska->packets[0], &matroska->packets[1],
@ -2168,7 +2168,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska)
int n; int n;
for (n = 0; n < matroska->num_packets; n++) { for (n = 0; n < matroska->num_packets; n++) {
av_free_packet(matroska->packets[n]); av_free_packet(matroska->packets[n]);
av_free(matroska->packets[n]); av_freep(&matroska->packets[n]);
} }
av_freep(&matroska->packets); av_freep(&matroska->packets);
matroska->num_packets = 0; matroska->num_packets = 0;
@ -3006,7 +3006,7 @@ static int matroska_read_close(AVFormatContext *s)
for (n = 0; n < matroska->tracks.nb_elem; n++) for (n = 0; n < matroska->tracks.nb_elem; n++)
if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO) if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO)
av_free(tracks[n].audio.buf); av_freep(&tracks[n].audio.buf);
ebml_free(matroska_cluster, &matroska->current_cluster); ebml_free(matroska_cluster, &matroska->current_cluster);
ebml_free(matroska_segment, matroska); ebml_free(matroska_segment, matroska);

Loading…
Cancel
Save