]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fixed left shift ubsan warning in PULLBYTE.
authorNathan Moinvaziri <nathan@nathanm.com>
Mon, 5 Oct 2020 01:36:25 +0000 (18:36 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 9 Oct 2020 09:31:03 +0000 (11:31 +0200)
  infback.c:200:13: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
  624: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/zlib-ng/zlib-ng/infback.c:200:13 in

infback.c

index 22599f0e865357a2fddeae881eded60c3b276fba..eecf03ada4d450624cf45d949b8afe088ca5fff8 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -80,7 +80,7 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB
     do { \
         PULL(); \
         have--; \
-        hold += (*next++ << bits); \
+        hold += ((unsigned)(*next++) << bits); \
         bits += 8; \
     } while (0)