Unified · Split
| @@ -95,7 +95,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 94 unmodified lines | ||
| 95 | 95 | |
| 96 | 96 | // allocate sub and set values |
| 97 | 97 | sub->rects = av_mallocz(sizeof(*sub->rects)); |
| 98 | + if (!sub->rects) | |
| 99 | + return AVERROR(ENOMEM); | |
| 98 | 100 | sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); |
| 101 | + if (!sub->rects[0]) { | |
| 102 | + av_freep(&sub->rects); | |
| 103 | + return AVERROR(ENOMEM); | |
| 104 | + } | |
| 99 | 105 | sub->num_rects = 1; |
| 100 | 106 | sub->rects[0]->x = x; sub->rects[0]->y = y; |
| 101 | 107 | sub->rects[0]->w = w; sub->rects[0]->h = h; |
| @@ -104,6 +110,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 2 unmodified lines | ||
| 104 | 110 | sub->rects[0]->pict.data[0] = av_malloc(w * h); |
| 105 | 111 | sub->rects[0]->nb_colors = 4; |
| 106 | 112 | sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); |
| 113 | + if (!sub->rects[0]->pict.data[0] || !sub->rects[0]->pict.data[1]) { | |
| 114 | + av_freep(&sub->rects[0]->pict.data[1]); | |
| 115 | + av_freep(&sub->rects[0]->pict.data[0]); | |
| 116 | + av_freep(&sub->rects[0]); | |
| 117 | + av_freep(&sub->rects); | |
| 118 | + return AVERROR(ENOMEM); | |
| 119 | + } | |
| 107 | 120 | |
| 108 | 121 | // read palette |
| 109 | 122 | for (i = 0; i < sub->rects[0]->nb_colors; i++) |