fix(video): avoid nullptr deref segfault on encode session teardown (#5257)

This commit is contained in:
Kishi
2026-06-28 22:11:35 +02:00
committed by GitHub
parent 16a654081e
commit 86a253859e
+2 -2
View File
@@ -418,8 +418,8 @@ namespace video {
avcodec_encode_session_t(avcodec_encode_session_t &&other) noexcept = default;
~avcodec_encode_session_t() {
// Flush any remaining frames in the encoder
if (avcodec_send_frame(avcodec_ctx.get(), nullptr) == 0) {
// Flush any remaining frames in the encoder if the encoder started up (frame num > 0)
if (avcodec_ctx->frame_num > 0 && avcodec_send_frame(avcodec_ctx.get(), nullptr) == 0) {
packet_raw_avcodec pkt;
while (avcodec_receive_packet(avcodec_ctx.get(), pkt.av_packet) == 0);
}