mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
media_encoder: avoid segfault on nullptr
Caught by ut_media_encoder: READ of size 8 at 0x602000029818 thread T0 #0 0x5649e914d6e0 in jami::MediaEncoder::send(AVPacket&, int) media/media_encoder.cpp:504 #1 0x5649e914d05c in jami::MediaEncoder::encode(AVFrame*, int) media/media_encoder.cpp:480 #2 0x5649e8cac119 in jami::test::MediaEncoderTest::testMultiStream() media/test_media_encoder.cpp:183 outputCtx_->nb_streams can be different from encoders.size(), and if not checked can lead to a crash Change-Id: I3c0217ec3e1d50950bf46989e0dd6797fee8972e
This commit is contained in:

committed by
Mohamed Chibani

parent
feb26e4741
commit
dc71d87c73
@ -495,7 +495,8 @@ MediaEncoder::send(AVPacket& pkt, int streamIdx)
|
||||
}
|
||||
if (streamIdx < 0)
|
||||
streamIdx = currentStreamIdx_;
|
||||
if (streamIdx >= 0 and static_cast<size_t>(streamIdx) < encoders_.size()) {
|
||||
if (streamIdx >= 0 and static_cast<size_t>(streamIdx) < encoders_.size()
|
||||
and static_cast<unsigned int>(streamIdx) < outputCtx_->nb_streams) {
|
||||
auto encoderCtx = encoders_[streamIdx];
|
||||
pkt.stream_index = streamIdx;
|
||||
if (pkt.pts != AV_NOPTS_VALUE)
|
||||
|
Reference in New Issue
Block a user