]> granicus.if.org Git - zziplib/commitdiff
string mapping 'comprlevel' should be indexed by length, not sizeof #42 #43
authorGuido Draheim <guidod@gmx.de>
Mon, 12 Mar 2018 22:06:57 +0000 (23:06 +0100)
committerGuido Draheim <guidod@gmx.de>
Mon, 12 Mar 2018 22:06:57 +0000 (23:06 +0100)
zzip/info.c

index 7415b880d937b5cbba7e178936a72ed7a3b4d5d8..2482576277590da0eaae1dd5ad0c24a40aa1ba6b 100644 (file)
@@ -58,6 +58,7 @@ zzip_dirfd(ZZIP_DIR * dir)
     return dir->fd;
 }
 
+#define LENGTH(x) (sizeof(x) / sizeof(*x))
 static const char* comprlevel[] = {
     "stored",   "shrunk",   "redu:1",   "redu:2",   "redu:3",   "redu:4",
     "impl:N",   "toknze",   "defl:N",   "defl:B",   "impl:B" };
@@ -69,7 +70,7 @@ static const char* comprlevel[] = {
 zzip_char_t *
 zzip_compr_str(int compr)
 {
-    if (0 <= compr && compr < sizeof(comprlevel))
+    if (0 <= compr && compr < LENGTH(comprlevel))
     {
         return comprlevel[compr];
     } else if (0 < compr && compr < 256)