Skip to content

Commit 2a9a98e

Browse files
committed
Protect against empty arrays
1 parent 4f42bca commit 2a9a98e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

CachedQuickLz/CachedQlzCommon.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public static int SizeCompressed(byte[] source)
3838
/// <returns>If the array is compressed with QuickLz or not</returns>
3939
public static bool IsCompressed(byte[] source, int length)
4040
{
41+
if (source == null || source.Length < QlzConstants.QlzTrailLength || length < QlzConstants.QlzTrailLength)
42+
return false;
43+
4144
var trailEquals = true;
4245
for (var i = length - 1; i > length - QlzConstants.QlzTrailLength; i--)
4346
{

0 commit comments

Comments
 (0)