Skip to content

Commit dc89a1d

Browse files
authored
Merge pull request #148 from RealAdarsh/feature/capacity-fix
Adds automatic buffer resizing capability
2 parents 5ea3135 + 48f0a9b commit dc89a1d

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/h__Reader.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,23 @@ ASDCP::Read_EKLV_Packet(Kumu::IFileReader& File, const ASDCP::Dictionary& Dict,
398398
}
399399
else if ( Key.MatchIgnoreStream(EssenceUL) ) // ignore the stream number
400400
{ // read plaintext frame
401-
if ( FrameBuf.Capacity() < PacketLength )
402-
{
403-
char intbuf[IntBufferLen];
404-
DefaultLogSink().Error("FrameBuf.Capacity: %u FrameLength: %s\n",
405-
FrameBuf.Capacity(), ui64sz(PacketLength, intbuf));
406-
return RESULT_SMALLBUF;
407-
}
401+
if ( FrameBuf.Capacity() < PacketLength )
402+
{
403+
Result_t resize_result = FrameBuf.Capacity((ui32_t)PacketLength);
404+
405+
if (ASDCP_SUCCESS(resize_result))
406+
{
407+
DefaultLogSink().Warn("FrameBuf automatically resized to %u bytes\n",
408+
(ui32_t)PacketLength);
409+
}
410+
else
411+
{
412+
char intbuf[IntBufferLen];
413+
DefaultLogSink().Error("FrameBuf.Capacity: %u FrameLength: %s (resize failed)\n",
414+
FrameBuf.Capacity(), ui64sz(PacketLength, intbuf));
415+
return RESULT_SMALLBUF;
416+
}
417+
}
408418

409419
// read the data into the supplied buffer
410420
ui32_t read_count;

0 commit comments

Comments
 (0)