Skip to content

Commit

Permalink
Merge from PR #18 (Fix for ReleaseMemory flag in commit operations)
Browse files Browse the repository at this point in the history
  • Loading branch information
ironfede committed Apr 14, 2018
2 parents 1ffb4e4 + f7e88dd commit 6e0a17e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sources/OpenMcdf/CompoundFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public void Commit(bool releaseMemory)
gap = true;
}

if (releaseMemory)
if ( s != null && releaseMemory)
{

s.ReleaseData();
Expand Down
20 changes: 18 additions & 2 deletions sources/Test/OpenMcdf.Test/CompoundFileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ public void Test_FIX_BUG_GH_15()
compoundFile.Close();

byte[] readBuffer = new byte[15];
compoundFile = new CompoundFile(filename);
compoundFile = new CompoundFile(filename);

byte c = 0x0A;
for (int i = 0; i < iterationCount; i++)
Expand All @@ -990,7 +990,23 @@ public void Test_FIX_BUG_GH_15()
compoundFile.Close();
}


[TestMethod]
public void Test_PR_GH_18()
{
try
{
var f = new CompoundFile("MultipleStorage4.cfs",CFSUpdateMode.Update,CFSConfiguration.Default);
var st = f.RootStorage.GetStorage("MyStorage").GetStorage("AnotherStorage").GetStream("MyStream");
st.Write(Helpers.GetBuffer(100, 0x02), 100);
f.Commit(true);
Assert.IsTrue(st.GetData().Count() == 31220);
f.Close();
}
catch (Exception ex)
{
Assert.Fail("Release Memory flag caused error");
}
}
//[TestMethod]
//public void Test_CORRUPTED_CYCLIC_DIFAT_VALIDATION_CHECK()
//{
Expand Down

0 comments on commit 6e0a17e

Please sign in to comment.