Skip to content

Commit 67224f7

Browse files
authored
Merge pull request zaphoyd#636 from gjasny/remove-undefined-behaviour
Avoid undefined behaviour at circular shift
2 parents 0b2e14e + 6578aae commit 67224f7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

websocketpp/frame.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,9 @@ inline size_t prepare_masking_key(const masking_key_type& key) {
610610
* to zero and less than sizeof(size_t).
611611
*/
612612
inline size_t circshift_prepared_key(size_t prepared_key, size_t offset) {
613+
if (offset == 0) {
614+
return prepared_key;
615+
}
613616
if (lib::net::is_little_endian()) {
614617
size_t temp = prepared_key << (sizeof(size_t)-offset)*8;
615618
return (prepared_key >> offset*8) | temp;

0 commit comments

Comments
 (0)