mp_image: check memory allocation

This commit is contained in:
wm4 2014-11-08 16:10:04 +01:00
parent 33b57f5557
commit 4235aab897
1 changed files with 4 additions and 0 deletions

View File

@ -689,6 +689,10 @@ struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img)
if (!new_ref) if (!new_ref)
return NULL; return NULL;
AVFrame *frame = av_frame_alloc(); AVFrame *frame = av_frame_alloc();
if (!frame) {
talloc_free(new_ref);
return NULL;
}
mp_image_copy_fields_to_av_frame(frame, new_ref); mp_image_copy_fields_to_av_frame(frame, new_ref);
// Caveat: if img has shared references, and all other references disappear // Caveat: if img has shared references, and all other references disappear
// at a later point, the AVFrame will still be read-only. // at a later point, the AVFrame will still be read-only.