Commit 49f3fb75 authored by François Grisez's avatar François Grisez
Browse files

Avoid crash while receiving an misformated FU header.

parent 0d0eb856
......@@ -54,10 +54,7 @@ mblk_t *H265NalUnpacker::FuAggregator::feed(mblk_t *packet) {
}
if (fuHeader.getPosition() == H265FuHeader::Position::End) {
mblk_t *m = _m;
msgpullup(m, -1);
_m = nullptr;
return m;
return completeAggregation();
} else return nullptr;
}
......@@ -67,7 +64,9 @@ void H265NalUnpacker::FuAggregator::reset() {
}
mblk_t *H265NalUnpacker::FuAggregator::completeAggregation() {
if (!isAggregating()) return nullptr;
mblk_t *res = _m;
msgpullup(res, -1);
_m = nullptr;
return res;
}
......
......@@ -18,7 +18,10 @@
*/
#include <bitset>
#include <stdexcept>
#include "mediastreamer2/msqueue.h"
#include "nal-unpacker.h"
using namespace std;
......@@ -87,9 +90,15 @@ NalUnpacker::Status NalUnpacker::unpack(mblk_t *im, MSQueue *out) {
storeNal(im);
break;
case PacketType::FragmentationUnit: {
ms_debug("Receiving FU-A");
mblk_t *o = _fuAggregator->feed(im);
if (o) storeNal(o);
try {
ms_debug("Receiving FU-A");
mblk_t *o = _fuAggregator->feed(im);
if (o) storeNal(o);
} catch (const invalid_argument &e) {
ms_error("%s", e.what());
_fuAggregator->reset();
_status.frameCorrupted = true;
}
break;
}
case PacketType::AggregationPacket:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment