From 07868a94759183341dad28cc13c9c3aa5c4832cb Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 28 Jan 2018 18:49:24 -0600 Subject: Only test for gzipped data if the data is long enough --- sx-encoding.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sx-encoding.el') diff --git a/sx-encoding.el b/sx-encoding.el index 3ce1d6b..63a3464 100644 --- a/sx-encoding.el +++ b/sx-encoding.el @@ -152,8 +152,10 @@ numbers identifying the gzip file format. See URL `http://www.gzip.org/zlib/rfc-gzip.html'." ;; Credit: http://emacs.stackexchange.com/a/2978 - (equal (substring (string-as-unibyte data) 0 2) - (unibyte-string 31 139))) + (let ((unidata (string-as-unibyte data))) + (when (<= 2 (length unidata)) + (equal (substring unidata 0 2) + (unibyte-string 31 139))))) (defun sx-encoding-gzipped-buffer-p (buffer) "Check if BUFFER is gzip-compressed. -- cgit v1.2.3