Fix incorrect casting and null references on DiscImageChef format.

This commit is contained in:
2018-01-29 17:10:57 +00:00
parent a6ca7a5134
commit 0b7565c072
2 changed files with 7 additions and 4 deletions

View File

@@ -761,7 +761,7 @@ namespace DiscImageChef.DiscImages
imageStream.Read(structureBytes, 0, structureBytes.Length);
structurePointer = Marshal.AllocHGlobal(Marshal.SizeOf(cicmBlock));
Marshal.Copy(structureBytes, 0, structurePointer, Marshal.SizeOf(cicmBlock));
cicmBlock = (CicmMetadataBlock)Marshal.PtrToStructure(structurePointer, typeof(GeometryBlock));
cicmBlock = (CicmMetadataBlock)Marshal.PtrToStructure(structurePointer, typeof(CicmMetadataBlock));
Marshal.FreeHGlobal(structurePointer);
if(cicmBlock.identifier != BlockType.CicmBlock) break;
@@ -895,8 +895,11 @@ namespace DiscImageChef.DiscImages
for(uint j = 0; j < dumpEntry.extents; j++)
{
imageStream.Read(tmp, 0, tmp.Length);
dump.Extents[0].Start = BitConverter.ToUInt64(tmp, 0);
dump.Extents[0].End = BitConverter.ToUInt64(tmp, 8);
dump.Extents[j] = new ExtentType
{
Start = BitConverter.ToUInt64(tmp, 0),
End = BitConverter.ToUInt64(tmp, 8)
};
}
dump.Extents = dump.Extents.OrderBy(t => t.Start).ToArray();