summaryrefslogtreecommitdiff
path: root/libavformat/nut.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2013-10-22 16:11:11 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2013-10-22 17:09:56 +0100
commitb1fcdc08ceb5df69fac34aa0d57c56905d32b8b4 (patch)
tree3d16b192feac83cd9e9dd63ec322b05d8dcc5640 /libavformat/nut.c
parent3511d4fc9784d5fbb024dce68ca7a0d7fdd74663 (diff)
nut: Fix unchecked allocations
CC: libav-stable@libav.org Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/nut.c')
-rw-r--r--libavformat/nut.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavformat/nut.c b/libavformat/nut.c
index 2e1d129ed7..d9a042bca0 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -185,11 +185,17 @@ int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b)
return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32);
}
-void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
+int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
{
Syncpoint *sp = av_mallocz(sizeof(Syncpoint));
struct AVTreeNode *node = av_tree_node_alloc();
+ if (!sp || !node) {
+ av_freep(&sp);
+ av_freep(&node);
+ return AVERROR(ENOMEM);
+ }
+
sp->pos = pos;
sp->back_ptr = back_ptr;
sp->ts = ts;
@@ -198,6 +204,8 @@ void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
av_free(sp);
av_free(node);
}
+
+ return 0;
}
static int enu_free(void *opaque, void *elem)