Skip to content

Commit 8d4cce5

Browse files
author
Clement Champetier
committed
coded data: raise a bad_alloc when faling to allocate the requested space
1 parent 5c788e3 commit 8d4cce5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/AvTranscoder/data/coded/CodedData.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ CodedData::CodedData()
1414
CodedData::CodedData(const size_t dataSize)
1515
: _avStream(NULL)
1616
{
17-
av_new_packet(&_packet, dataSize);
17+
const int err = av_new_packet(&_packet, dataSize);
18+
if(err != 0)
19+
{
20+
LOG_ERROR("Unable to allocate the payload of a packet and initialize its fields with default values: " << getDescriptionFromErrorCode(err))
21+
throw std::bad_alloc();
22+
}
1823
}
1924

2025
CodedData::CodedData(const AVPacket& avPacket)

0 commit comments

Comments
 (0)