From: Guido Draheim Date: Mon, 12 Mar 2018 22:06:57 +0000 (+0100) Subject: string mapping 'comprlevel' should be indexed by length, not sizeof #42 #43 X-Git-Tag: v0.13.69~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7363712d7f95807adc4c607af4604408cda036f4;p=zziplib string mapping 'comprlevel' should be indexed by length, not sizeof #42 #43 --- diff --git a/zzip/info.c b/zzip/info.c index 7415b88..2482576 100644 --- a/zzip/info.c +++ b/zzip/info.c @@ -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)