History

Plug memory leak in NUT muxer and demuxer

Originally committed as revision 22174 to svn://svn.ffmpeg.org/ffmpeg/trunk

Vitor Sessak committed 16 years ago

Commit 4b83fc01 parent 1f6d0d48 files · +31 −3Browse files

Unified · Split

8 files
  1. doc/APIchanges +3 −0
  2. libavformat/nut.c +11 −0
  3. libavformat/nut.h +1 −0
  4. libavformat/nutdec.c +1 −0
  5. libavformat/nutenc.c +1 −0
  6. libavutil/avutil.h +1 −1
  7. libavutil/tree.c +0 −2
  8. libavutil/tree.h +13 −0
doc/APIchanges+3−0
@@ -12,6 +12,9 @@ libavutil: 2009-03-08 · 11 unmodified lines
12 12
13API changes, most recent first:13API changes, most recent first:
14 14
152010-03-03 - r22174 - lavu 50.10.0 - av_tree_enumerate()
16 Add av_tree_enumerate().
17
152010-02-07 - r21673 - lavu 50.9.0 - av_compare_ts()182010-02-07 - r21673 - lavu 50.9.0 - av_compare_ts()
16 Add av_compare_ts().19 Add av_compare_ts().
17 20
libavformat/nut.c+11−0
@@ -69,6 +69,17 @@ void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){ · 68 unmodified lines
69 }69 }
70}70}
71 71
72static void enu_free(void *opaque, void *elem)
73{
74 av_free(elem);
75}
76
77void ff_nut_free_sp(NUTContext *nut)
78{
79 av_tree_enumerate(nut->syncpoints, NULL, NULL, enu_free);
80 av_tree_destroy(nut->syncpoints);
81}
82
72const Dispositions ff_nut_dispositions[] = {83const Dispositions ff_nut_dispositions[] = {
73 {"default" , AV_DISPOSITION_DEFAULT},84 {"default" , AV_DISPOSITION_DEFAULT},
74 {"dub" , AV_DISPOSITION_DUB},85 {"dub" , AV_DISPOSITION_DUB},
libavformat/nut.h+1−0
@@ -110,6 +110,7 @@ int64_t ff_lsb2full(StreamContext *stream, int64_t lsb); · 109 unmodified lines
110int ff_nut_sp_pos_cmp(Syncpoint *a, Syncpoint *b);110int ff_nut_sp_pos_cmp(Syncpoint *a, Syncpoint *b);
111int ff_nut_sp_pts_cmp(Syncpoint *a, Syncpoint *b);111int ff_nut_sp_pts_cmp(Syncpoint *a, Syncpoint *b);
112void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);112void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
113void ff_nut_free_sp(NUTContext *nut);
113 114
114extern const Dispositions ff_nut_dispositions[];115extern const Dispositions ff_nut_dispositions[];
115 116
libavformat/nutdec.c+1−0
@@ -901,6 +901,7 @@ static int nut_read_close(AVFormatContext *s) · 900 unmodified lines
901 901
902 av_freep(&nut->time_base);902 av_freep(&nut->time_base);
903 av_freep(&nut->stream);903 av_freep(&nut->stream);
904 ff_nut_free_sp(nut);
904 for(i = 1; i < nut->header_count; i++)905 for(i = 1; i < nut->header_count; i++)
905 av_freep(&nut->header[i]);906 av_freep(&nut->header[i]);
906 907
libavformat/nutenc.c+1−0
@@ -797,6 +797,7 @@ static int write_trailer(AVFormatContext *s){ · 796 unmodified lines
797 while(nut->header_count<3)797 while(nut->header_count<3)
798 write_headers(nut, bc);798 write_headers(nut, bc);
799 put_flush_packet(bc);799 put_flush_packet(bc);
800 ff_nut_free_sp(nut);
800 av_freep(&nut->stream);801 av_freep(&nut->stream);
801 av_freep(&nut->time_base);802 av_freep(&nut->time_base);
802 803
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
40#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)40#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
42#define LIBAVUTIL_VERSION_MAJOR 5042#define LIBAVUTIL_VERSION_MAJOR 50
43#define LIBAVUTIL_VERSION_MINOR 943#define LIBAVUTIL_VERSION_MINOR 10
44#define LIBAVUTIL_VERSION_MICRO 044#define LIBAVUTIL_VERSION_MICRO 0
45 45
46#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \46#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
libavutil/tree.c+0−2
@@ -135,7 +135,6 @@ void av_tree_destroy(AVTreeNode *t){ · 134 unmodified lines
135 }135 }
136}136}
137 137
138#if 0
139void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){138void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){
140 if(t){139 if(t){
141 int v= cmp ? cmp(opaque, t->elem) : 0;140 int v= cmp ? cmp(opaque, t->elem) : 0;
@@ -144,7 +143,6 @@ void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, voi · 2 unmodified lines
144 if(v<=0) av_tree_enumerate(t->child[1], opaque, cmp, enu);143 if(v<=0) av_tree_enumerate(t->child[1], opaque, cmp, enu);
145 }144 }
146}145}
147#endif
148 146
149#ifdef TEST147#ifdef TEST
150 148
libavutil/tree.h+13−0
@@ -79,4 +79,17 @@ void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *ke · 78 unmodified lines
79void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next);79void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next);
80void av_tree_destroy(struct AVTreeNode *t);80void av_tree_destroy(struct AVTreeNode *t);
81 81
82/**
83 * Applies enu(opaque, &elem) to all the elements in the tree in a given range.
84 *
85 * @param cmp a comparison function that returns < 0 for a element below the
86 * range, > 0 for a element above the range and == 0 for a
87 * element inside the range
88 *
89 * @note The cmp function should use the same ordering used to construct the
90 * tree.
91 */
92void av_tree_enumerate(struct AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem));
93
94
82#endif /* AVUTIL_TREE_H */95#endif /* AVUTIL_TREE_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t