From 07070076d1baea4aa84aca817e284a63c358a149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20Kr=C3=B6ger?= Date: Mon, 20 Jun 2016 13:58:31 +0200 Subject: [PATCH] [PR] Fixed pointer overflow crash when using bgsave under rare circumstances. --- src/Win32_Interop/Win32_Common.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Win32_Interop/Win32_Common.cpp b/src/Win32_Interop/Win32_Common.cpp index 5e0653179ce..2fbce821b08 100644 --- a/src/Win32_Interop/Win32_Common.cpp +++ b/src/Win32_Interop/Win32_Common.cpp @@ -37,10 +37,9 @@ void EnsureMemoryIsMapped(const void *buffer, size_t size) { if ((size_t) (pEnd - pStart) > Globals::pageSize) { size_t offset = 0; while (offset < size) { - if (size < offset) { + offset += Globals::pageSize; + if (offset > size) { offset = size; - } else { - offset += Globals::pageSize; } c = *((char*) (p + offset)); }