ref:86a253859e2eac62f41a2821804efa90ae8215c8

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

SHA: 86a253859e2eac62f41a2821804efa90ae8215c8
Author: Kishi <41839133+Kishi85@users.noreply.github.com>
Date: 2026-06-28 20:11
Parents: 16a6540
1 files changed +2 -2
Type
src/video.cpp +2 −2
@@ -418,8 +418,8 @@
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);
}