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
1212
1313 API changes, most recent first:
1414
15+2010-03-03 - r22174 - lavu 50.10.0 - av_tree_enumerate()
16+ Add av_tree_enumerate().
17+
1518 2010-02-07 - r21673 - lavu 50.9.0 - av_compare_ts()
1619 Add av_compare_ts().
1720
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
6969 }
7070 }
7171
72+static void enu_free(void *opaque, void *elem)
73+{
74+ av_free(elem);
75+}
76+
77+void 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+
7283 const Dispositions ff_nut_dispositions[] = {
7384 {"default" , AV_DISPOSITION_DEFAULT},
7485 {"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
110110 int ff_nut_sp_pos_cmp(Syncpoint *a, Syncpoint *b);
111111 int ff_nut_sp_pts_cmp(Syncpoint *a, Syncpoint *b);
112112 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
113+void ff_nut_free_sp(NUTContext *nut);
113114
114115 extern const Dispositions ff_nut_dispositions[];
115116
libavformat/nutdec.c+1−0
@@ -901,6 +901,7 @@ static int nut_read_close(AVFormatContext *s) · 900 unmodified lines
901901
902902 av_freep(&nut->time_base);
903903 av_freep(&nut->stream);
904+ ff_nut_free_sp(nut);
904905 for(i = 1; i < nut->header_count; i++)
905906 av_freep(&nut->header[i]);
906907
libavformat/nutenc.c+1−0
@@ -797,6 +797,7 @@ static int write_trailer(AVFormatContext *s){ · 796 unmodified lines
797797 while(nut->header_count<3)
798798 write_headers(nut, bc);
799799 put_flush_packet(bc);
800+ ff_nut_free_sp(nut);
800801 av_freep(&nut->stream);
801802 av_freep(&nut->time_base);
802803
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 50
43−#define LIBAVUTIL_VERSION_MINOR 9
43+#define LIBAVUTIL_VERSION_MINOR 10
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #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
135135 }
136136 }
137137
138−#if 0
139138 void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){
140139 if(t){
141140 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
144143 if(v<=0) av_tree_enumerate(t->child[1], opaque, cmp, enu);
145144 }
146145 }
147−#endif
148146
149147 #ifdef TEST
150148
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
7979 void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next);
8080 void av_tree_destroy(struct AVTreeNode *t);
8181
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+ */
92+void av_tree_enumerate(struct AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem));
93+
94+
8295 #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