Revision 65d4cab5 libavfilter/defaults.c

View differences:

libavfilter/defaults.c
35 35
AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
36 36
{
37 37
    AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
38
    AVFilterBufferRef *ref = av_mallocz(sizeof(AVFilterBufferRef));
38
    AVFilterBufferRef *ref = NULL;
39 39
    int i, tempsize;
40
    char *buf;
40
    char *buf = NULL;
41

  
42
    if (!pic || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
43
        goto fail;
41 44

  
42 45
    ref->buf         = pic;
43 46
    ref->video       = av_mallocz(sizeof(AVFilterBufferRefVideoProps));
......
58 61
    tempsize = av_fill_image_pointers(pic->data, ref->format, ref->video->h, NULL, pic->linesize);
59 62
    buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
60 63
                                    // SIMD-friendly
64
    if (!buf)
65
        goto fail;
61 66
    av_fill_image_pointers(pic->data, ref->format, ref->video->h, buf, pic->linesize);
62 67

  
63 68
    memcpy(ref->data,     pic->data,     sizeof(ref->data));
64 69
    memcpy(ref->linesize, pic->linesize, sizeof(ref->linesize));
65 70

  
66 71
    return ref;
72

  
73
fail:
74
    av_free(buf);
75
    if (ref && ref->video)
76
        av_free(ref->video);
77
    av_free(ref);
78
    av_free(pic);
79
    return NULL;
67 80
}
68 81

  
69 82
void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)

Also available in: Unified diff