Skip other null writes for other packages

This commit is contained in:
Matt Nadareski
2022-05-22 10:21:54 -07:00
parent ac0ed050dc
commit 2ce8bda394
3 changed files with 19 additions and 3 deletions

View File

@@ -1113,7 +1113,12 @@ namespace LibMSPackSharp.CHM
/// </summary>
private static int SysWrite(object file, byte[] buffer, int offset, int bytes)
{
if (file is DecompressorImpl self)
// Null output file means skip those bytes
if (file == null)
{
return bytes;
}
else if (file is DecompressorImpl self)
{
self.State.Offset += (uint)bytes;
if (self.State.OutputFileHandle != null)

View File

@@ -86,7 +86,12 @@ namespace LibMSPackSharp.OAB
private static int SysWrite(object baseFile, byte[] buf, int pointer, int size)
{
if (baseFile is InternalFile file)
// Null output file means skip those bytes
if (baseFile == null)
{
return size;
}
else if (baseFile is InternalFile file)
{
int bytes_written = file.OrigSys.Write(file.OrigFile, buf, pointer, size);
if (bytes_written > 0)
@@ -100,7 +105,7 @@ namespace LibMSPackSharp.OAB
}
// Unknown file to write to
return 0;
return -1;
}
#endregion

View File

@@ -252,6 +252,12 @@ namespace LibMSPackSharp
private static int DefaultWrite(object file, byte[] buffer, int pointer, int bytes)
{
// Null output file means skip those bytes
if (file == null)
{
return bytes;
}
FileStream self = file as FileStream;
if (self != null && buffer != null && bytes >= 0)
{