Skip to content

Commit a61b6b9

Browse files
authored
Merge pull request #128 from Numpsy/users/rw/blob_length
Write the length field when writing a VT_BLOB property
2 parents 591eaea + 14b6b1c commit a61b6b9

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -647,17 +647,24 @@ public VT_CF_Property(VTPropertyType vType, bool isVariant) : base(vType, isVari
647647
public override object ReadScalarValue(System.IO.BinaryReader br)
648648
{
649649

650-
int size = br.ReadInt32();
651-
byte[] data = br.ReadBytes(size);
650+
uint size = br.ReadUInt32();
651+
byte[] data = br.ReadBytes((int)size);
652652
return data;
653653
//br.ReadUInt16();//padding
654654
}
655655

656656
public override void WriteScalarValue(BinaryWriter bw, object pValue)
657657
{
658658
byte[] r = pValue as byte[];
659-
if (r != null)
659+
if (r is null)
660+
{
661+
bw.Write(0u);
662+
}
663+
else
664+
{
665+
bw.Write((uint)r.Length);
660666
bw.Write(r);
667+
}
661668
}
662669

663670
}
@@ -671,17 +678,23 @@ public VT_BLOB_Property(VTPropertyType vType, bool isVariant) : base(vType, isVa
671678

672679
public override object ReadScalarValue(System.IO.BinaryReader br)
673680
{
674-
int size = br.ReadInt32();
675-
byte[] data = br.ReadBytes(size);
681+
uint size = br.ReadUInt32();
682+
byte[] data = br.ReadBytes((int)size);
676683
return data;
677684
}
678685

679686
public override void WriteScalarValue(BinaryWriter bw, object pValue)
680687
{
681688
byte[] r = pValue as byte[];
682-
if (r != null)
689+
if (r is null)
690+
{
691+
bw.Write(0u);
692+
}
693+
else
694+
{
695+
bw.Write((uint)r.Length);
683696
bw.Write(r);
684-
697+
}
685698
}
686699

687700
}

0 commit comments

Comments
 (0)