[master] 9d1adbc Plug another left shift of a negative value

Federico G. Schwindt fgsch at lodoss.net
Sun Apr 30 01:43:05 CEST 2017


commit 9d1adbc5e4be7ab0c9884437b2ce6281edf41d02
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sun Apr 30 00:32:13 2017 +0100

    Plug another left shift of a negative value
    
    From upstream:
    
    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.

diff --git a/lib/libvgz/deflate.c b/lib/libvgz/deflate.c
index 24cfb77..4a7c6b3 100644
--- a/lib/libvgz/deflate.c
+++ b/lib/libvgz/deflate.c
@@ -157,7 +157,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



More information about the varnish-commit mailing list