[master] ea11115 Protect the CLEAR_HASH macro from zlib

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri May 12 13:14:06 CEST 2017


commit ea111153098fe636f7c42ab8da4efdc5954e894e
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri May 12 13:09:56 2017 +0200

    Protect the CLEAR_HASH macro from zlib
    
    Spotted by Coverity:
    
        /lib/libvgz/deflate.c: 605 in deflateParams()
        599     }
        600     if (s->level != level) {
        601         if (s->level == 0 && s->matches != 0) {
        602             if (s->matches == 1)
        603                 slide_hash(s);
        604             else
        >>> CID 1401053:  Control flow issues  (NESTING_INDENT_MISMATCH)
        >>> The macro on this line expands into multiple statements, only
        >>> the first of which is nested within the preceding parent while
        >>> the rest are not.
        605                 CLEAR_HASH(s);
        606             s->matches = 0;
        607         }
        608         s->level = level;
        609         s->max_lazy_match   = configuration_table[level].max_lazy;
        610         s->good_match       = configuration_table[level].good_length;

diff --git a/lib/libvgz/deflate.c b/lib/libvgz/deflate.c
index b3adb63..c796cb8 100644
--- a/lib/libvgz/deflate.c
+++ b/lib/libvgz/deflate.c
@@ -191,8 +191,10 @@ local const config configuration_table[10] = {
  * prev[] will be initialized on the fly.
  */
 #define CLEAR_HASH(s) \
+do { \
     s->head[s->hash_size-1] = NIL; \
-    zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+    zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); \
+} while (0)
 
 /* ===========================================================================
  * Slide the hash table when sliding the window down (could be avoided with 32



More information about the varnish-commit mailing list