diff --git a/GameRes/Checksum.cs b/GameRes/Checksum.cs index d6bbb257..435b3dd9 100644 --- a/GameRes/Checksum.cs +++ b/GameRes/Checksum.cs @@ -114,6 +114,8 @@ namespace GameRes.Utility public static uint Compute (byte[] buf, int pos, int len) { + if (0 == len) + return 1; unsafe { fixed (byte* ptr = &buf[pos]) @@ -224,6 +226,8 @@ namespace GameRes.Utility public void Update (byte[] buf, int pos, int len) { + if (0 == len) + return; unsafe { fixed (byte* ptr = &buf[pos]) diff --git a/GameRes/ZLibStream.cs b/GameRes/ZLibStream.cs index 0beb7a4b..3e7ff6db 100644 --- a/GameRes/ZLibStream.cs +++ b/GameRes/ZLibStream.cs @@ -179,8 +179,11 @@ namespace GameRes.Compression public override void Write (byte[] buffer, int offset, int count) { - m_adler.Write (buffer, offset, count); - m_total_in += count; + if (count > 0) + { + m_adler.Write (buffer, offset, count); + m_total_in += count; + } } public override void WriteByte (byte value)