History

avcodec/nvenc: fix segfault in intra-only mode

In intra-only mode, frameIntervalP is 0, which means the frame data array is smaller than the number of surfaces. Together with using the wrong size on deallocation of the frame_data_array, this lead to a crash.

Josh Allmann committed 2 years ago

Commit c9151ea1 parent cc6fb161 file · +2 −2Browse files

Unified · Split

libavcodec/nvenc.c+2−2
@@ -1021,7 +1021,7 @@ static av_cold int nvenc_recalc_surfaces(AVCodecContext *avctx) · 1020 unmodified lines
10211021
10221022 // Output in the worst case will only start when the surface buffer is completely full.
10231023 // Hence we need to keep at least the max amount of surfaces plus the max reorder delay around.
1024− ctx->frame_data_array_nb = ctx->nb_surfaces + ctx->encode_config.frameIntervalP - 1;
1024+ ctx->frame_data_array_nb = FFMAX(ctx->nb_surfaces, ctx->nb_surfaces + ctx->encode_config.frameIntervalP - 1);
10251025
10261026 return 0;
10271027 }
@@ -1984,7 +1984,7 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) · 956 unmodified lines
19841984 av_fifo_freep2(&ctx->unused_surface_queue);
19851985
19861986 if (ctx->frame_data_array) {
1987− for (i = 0; i < ctx->nb_surfaces; i++)
1987+ for (i = 0; i < ctx->frame_data_array_nb; i++)
19881988 av_buffer_unref(&ctx->frame_data_array[i].frame_opaque_ref);
19891989 av_freep(&ctx->frame_data_array);
19901990 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t