From 8a979f6c7986574e37316148cd8ca440c3bc08a3 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Sun, 5 Jul 2015 13:51:50 -0700 Subject: Avoid left shift of a negative value in flush rank calculation. The C standard permits an undefined result for a left shift of a negative value. --- deflate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deflate.c b/deflate.c index c042ac2..aeabbae 100644 --- a/deflate.c +++ b/deflate.c @@ -156,7 +156,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) +#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) /* =========================================================================== * Update a hash value with the given input byte -- cgit v1.2.3-55-g6feb