Commit b7e9e3e4 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - fix bug

parent ce6c064a
...@@ -35,8 +35,8 @@ namespace DocFileFormat ...@@ -35,8 +35,8 @@ namespace DocFileFormat
{ {
Record::~Record() Record::~Record()
{ {
RELEASEARRAYOBJECTS( this->RawData ); RELEASEARRAYOBJECTS( RawData );
RELEASEOBJECT( this->Reader ); RELEASEOBJECT( Reader );
} }
/*========================================================================================================*/ /*========================================================================================================*/
...@@ -53,20 +53,27 @@ namespace DocFileFormat ...@@ -53,20 +53,27 @@ namespace DocFileFormat
HeaderSize(0), BodySize(0), RawData(NULL), SiblingIdx(0), TypeCode(0), Version(0), Instance(0), Reader(NULL), HeaderSize(0), BodySize(0), RawData(NULL), SiblingIdx(0), TypeCode(0), Version(0), Instance(0), Reader(NULL),
_ParentRecord(NULL) _ParentRecord(NULL)
{ {
this->BodySize = bodySize; BodySize = bodySize;
this->TypeCode = typeCode; TypeCode = typeCode;
this->Version = version; Version = version;
this->Instance = instance; Instance = instance;
this->HeaderSize = Record::HEADER_SIZE_IN_BYTES; HeaderSize = Record::HEADER_SIZE_IN_BYTES;
this->RawData = _reader->ReadBytes( (int)this->BodySize, true ); int real_size = _reader->GetSize() - _reader->GetPosition();
this->Reader = new MemoryStream( this->RawData, this->BodySize, false );
if (real_size < BodySize)
{
BodySize = real_size;
}
RawData = _reader->ReadBytes( BodySize, true );
Reader = new MemoryStream( RawData, BodySize, false );
} }
/*========================================================================================================*/ /*========================================================================================================*/
unsigned int Record::GetTotalSize() const unsigned int Record::GetTotalSize() const
{ {
return ( this->HeaderSize + this->BodySize ); return ( HeaderSize + BodySize );
} }
} }
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