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

View File

@@ -810,7 +810,7 @@ typedef struct
uint length; uint length;
uint64 crc64 <format=hex>; uint64 crc64 <format=hex>;
DumpHardwareEntry dumpHardware[entries]; DumpHardwareEntry dumpHardware[entries];
} DumpHardwareHeader; } DumpHardwareHeader <optimize=false>;
typedef struct typedef struct
{ {