From 60e6671e4c4d513372b76aec247c22fd5bb83c46 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 7 Jan 2019 19:19:51 +1300 Subject: [PATCH] Use add_overflows() to update WSAOVERLAPPED --- xapian-core/net/remoteconnection.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xapian-core/net/remoteconnection.cc b/xapian-core/net/remoteconnection.cc index ecbb27524..2636ddf53 100644 --- a/xapian-core/net/remoteconnection.cc +++ b/xapian-core/net/remoteconnection.cc @@ -46,6 +46,7 @@ #include "fd.h" #include "filetests.h" #include "omassert.h" +#include "overflow.h" #include "posixy_wrapper.h" #include "realtime.h" #include "length.h" @@ -80,10 +81,8 @@ throw_timeout(const char* msg, const string& context) static inline void update_overlapped_offset(WSAOVERLAPPED & overlapped, DWORD n) { - // Signed overflow is undefined so check DWORD is unsigned. - static_assert(std::is_unsigned::value, "Type DWORD should be unsigned"); - overlapped.Offset += n; - if (overlapped.Offset < n) ++overlapped.OffsetHigh; + if (add_overflows(overlapped.Offset, n, overlapped.Offset)) + ++overlapped.OffsetHigh; } #endif -- 2.11.4.GIT