BugFix: crash when FrameMerger::flush

In a lambda expression, temporary stack variables should not be captured; otherwise,
the variables may have become invalid when FrameMerger::flush is called.
This commit is contained in:
xia-chu
2023-12-14 17:28:21 +08:00
parent 07f3c6dde4
commit c0bb7db476
3 changed files with 4 additions and 4 deletions

View File

@@ -111,7 +111,7 @@ void DecoderImp::onDecode(int stream, int codecid, int flags, int64_t pts, int64
onTrack(stream, Factory::getTrackByCodecId(codec, 8000, 1, 16));
}
if (!ref.first) {
WarnL << "not support codec :" << getCodecName(codec);
WarnL << "Unsupported codec :" << getCodecName(codec);
return;
}
auto frame = Factory::getFrameFromPtr(codec, (char *)data, bytes, dts, pts);
@@ -119,7 +119,7 @@ void DecoderImp::onDecode(int stream, int codecid, int flags, int64_t pts, int64
onFrame(stream, frame);
return;
}
ref.second.inputFrame(frame, [&](uint64_t dts, uint64_t pts, const Buffer::Ptr &buffer, bool) {
ref.second.inputFrame(frame, [this, stream, codec](uint64_t dts, uint64_t pts, const Buffer::Ptr &buffer, bool) {
onFrame(stream, Factory::getFrameFromBuffer(codec, buffer, dts, pts));
});
}