Fixes a null ptr deref
Showing the changes to libavfilter/src_buffer.c (1 of 1 file). Show all
Unified · Split
| @@ -270,6 +270,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, · 269 unmodified lines | ||
| 270 | 270 | case AVMEDIA_TYPE_VIDEO: |
| 271 | 271 | buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, |
| 272 | 272 | ref->video->w, ref->video->h); |
| 273 | + if(!buf) | |
| 274 | + return NULL; | |
| 273 | 275 | av_image_copy(buf->data, buf->linesize, |
| 274 | 276 | (void*)ref->data, ref->linesize, |
| 275 | 277 | ref->format, ref->video->w, ref->video->h); |
| @@ -278,6 +280,8 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, · 2 unmodified lines | ||
| 278 | 280 | case AVMEDIA_TYPE_AUDIO: |
| 279 | 281 | buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, |
| 280 | 282 | ref->audio->nb_samples); |
| 283 | + if(!buf) | |
| 284 | + return NULL; | |
| 281 | 285 | channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); |
| 282 | 286 | av_samples_copy(buf->extended_data, ref->buf->extended_data, |
| 283 | 287 | 0, 0, ref->audio->nb_samples, |
| @@ -319,6 +323,8 @@ int av_buffersrc_add_ref(AVFilterContext *buffer_filter, · 35 unmodified lines | ||
| 319 | 323 | buf = picref; |
| 320 | 324 | else |
| 321 | 325 | buf = copy_buffer_ref(buffer_filter, picref); |
| 326 | + if(!buf) | |
| 327 | + return -1; | |
| 322 | 328 | |
| 323 | 329 | if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) { |
| 324 | 330 | if (buf != picref) |