From 2a9a98e182d273563f98fd4a956f206ab409269c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20V=C3=A1zquez=20=28Dagger=29?= Date: Fri, 19 Oct 2018 21:18:07 +0200 Subject: [PATCH] Protect against empty arrays --- CachedQuickLz/CachedQlzCommon.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CachedQuickLz/CachedQlzCommon.cs b/CachedQuickLz/CachedQlzCommon.cs index 4f58d5a..7b8cc9e 100644 --- a/CachedQuickLz/CachedQlzCommon.cs +++ b/CachedQuickLz/CachedQlzCommon.cs @@ -38,6 +38,9 @@ public static int SizeCompressed(byte[] source) /// If the array is compressed with QuickLz or not public static bool IsCompressed(byte[] source, int length) { + if (source == null || source.Length < QlzConstants.QlzTrailLength || length < QlzConstants.QlzTrailLength) + return false; + var trailEquals = true; for (var i = length - 1; i > length - QlzConstants.QlzTrailLength; i--) {