From b5c69ff7c71a612aceafb1e1e8c299a2295d6a0c Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 22 Jun 2017 08:56:46 -0700 Subject: [PATCH] Fix integer types in deflate_stream::bi_reverse --- CHANGELOG.md | 1 + include/beast/zlib/detail/deflate_stream.hpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 314d81b3..9cf1ddac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 65: * Enable narrowing warning on msvc cmake +* Fix integer types in deflate_stream::bi_reverse -------------------------------------------------------------------------------- diff --git a/include/beast/zlib/detail/deflate_stream.hpp b/include/beast/zlib/detail/deflate_stream.hpp index 03fdcd33..b37792f9 100644 --- a/include/beast/zlib/detail/deflate_stream.hpp +++ b/include/beast/zlib/detail/deflate_stream.hpp @@ -646,9 +646,10 @@ protected: init(); } + template static - unsigned - bi_reverse(unsigned code, int len); + Unsigned + bi_reverse(Unsigned code, unsigned len); template static @@ -742,12 +743,15 @@ protected: //-------------------------------------------------------------------------- // Reverse the first len bits of a code +template inline -unsigned +Unsigned deflate_stream:: -bi_reverse(unsigned code, int len) +bi_reverse(Unsigned code, unsigned len) { - unsigned res = 0; + BOOST_STATIC_ASSERT(std::is_unsigned::value); + BOOST_ASSERT(len <= 8 * sizeof(unsigned)); + Unsigned res = 0; do { res |= code & 1;