Ernst Albrecht Köstlin <[email protected]> added the comment:
So what about this? The same as before but all AVStream related clean up moved
to the new function "av_delete_stream", as far as it was setup by
"av_new_stream". The codec->rc_eq stuff still needs to be cleaned up by calling
ffm_close.
Grz
/a
--- libavformat/avformat.h 2010-07-20 22:20:14.000000000 +0200
+++ libavformat/avformat_patched.h 2010-07-20 22:20:00.000000000 +0200
@@ -1086,6 +1086,7 @@
* @param id file-format-dependent stream ID
*/
AVStream *av_new_stream(AVFormatContext *s, int id);
+void av_delete_stream(AVStream ** st);
AVProgram *av_new_program(AVFormatContext *s, int id);
/**
--- libavformat/utils.c 2010-07-20 22:19:33.000000000 +0200
+++ libavformat/utils_patched.c 2010-07-20 22:21:19.000000000 +0200
@@ -2497,6 +2497,13 @@
url_fclose(pb);
}
+void av_delete_stream(AVStream ** st)
+{
+ if (*st)
+ av_freep(&((*st)->codec));
+ av_freep(st);
+}
+
AVStream *av_new_stream(AVFormatContext *s, int id)
{
AVStream *st;
--- libavformat/ffmdec.c 2010-07-20 22:25:46.000000000 +0200
+++ libavformat/ffmdec_patched.c 2010-07-20 22:20:38.000000000 +0200
@@ -251,6 +251,7 @@
url_fseek(pb, ptr, SEEK_SET);
}
+static int ffm_close(AVFormatContext *);
static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
@@ -381,12 +382,11 @@
ffm->first_packet = 1;
return 0;
fail:
+ ffm_close(s);
for(i=0;i<s->nb_streams;i++) {
- st = s->streams[i];
- if (st) {
- av_free(st);
- }
+ av_delete_stream(&s->streams[i]);
}
+ s->nb_streams = 0;
return -1;
}
________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/issue2003>
________________________________________________