CC: libav-stable@libav.org
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
... | ... |
@@ -185,11 +185,17 @@ int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b) |
185 | 185 |
return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32); |
186 | 186 |
} |
187 | 187 |
|
188 |
-void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts) |
|
188 |
+int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts) |
|
189 | 189 |
{ |
190 | 190 |
Syncpoint *sp = av_mallocz(sizeof(Syncpoint)); |
191 | 191 |
struct AVTreeNode *node = av_tree_node_alloc(); |
192 | 192 |
|
193 |
+ if (!sp || !node) { |
|
194 |
+ av_freep(&sp); |
|
195 |
+ av_freep(&node); |
|
196 |
+ return AVERROR(ENOMEM); |
|
197 |
+ } |
|
198 |
+ |
|
193 | 199 |
sp->pos = pos; |
194 | 200 |
sp->back_ptr = back_ptr; |
195 | 201 |
sp->ts = ts; |
... | ... |
@@ -198,6 +204,8 @@ void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts) |
198 | 198 |
av_free(sp); |
199 | 199 |
av_free(node); |
200 | 200 |
} |
201 |
+ |
|
202 |
+ return 0; |
|
201 | 203 |
} |
202 | 204 |
|
203 | 205 |
static int enu_free(void *opaque, void *elem) |
... | ... |
@@ -118,7 +118,7 @@ void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val); |
118 | 118 |
int64_t ff_lsb2full(StreamContext *stream, int64_t lsb); |
119 | 119 |
int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b); |
120 | 120 |
int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b); |
121 |
-void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts); |
|
121 |
+int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts); |
|
122 | 122 |
void ff_nut_free_sp(NUTContext *nut); |
123 | 123 |
|
124 | 124 |
extern const Dispositions ff_nut_dispositions[]; |
... | ... |
@@ -532,6 +532,7 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr) |
532 | 532 |
AVFormatContext *s = nut->avf; |
533 | 533 |
AVIOContext *bc = s->pb; |
534 | 534 |
int64_t end, tmp; |
535 |
+ int ret; |
|
535 | 536 |
|
536 | 537 |
nut->last_syncpoint_pos = avio_tell(bc) - 8; |
537 | 538 |
|
... | ... |
@@ -553,7 +554,9 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr) |
553 | 553 |
|
554 | 554 |
*ts = tmp / s->nb_streams * |
555 | 555 |
av_q2d(nut->time_base[tmp % s->nb_streams]) * AV_TIME_BASE; |
556 |
- ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts); |
|
556 |
+ |
|
557 |
+ if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts)) < 0) |
|
558 |
+ return ret; |
|
557 | 559 |
|
558 | 560 |
return 0; |
559 | 561 |
} |
... | ... |
@@ -815,7 +815,8 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) |
815 | 815 |
ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos) >> 4 : 0); |
816 | 816 |
put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE); |
817 | 817 |
|
818 |
- ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts); |
|
818 |
+ if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0) |
|
819 |
+ return ret; |
|
819 | 820 |
} |
820 | 821 |
assert(nus->last_pts != AV_NOPTS_VALUE); |
821 | 822 |
|