Skip to content

Commit feedfb7

Browse files
committed
fix(Foundation): add missing <limits> include in SharedMemory_WIN32 (#5176)
std::numeric_limits<DWORD> is used in the Win32 path but <limits> was never included directly, causing build failures when cross-compiling from Linux (e.g. MinGW on Debian 12) where the header is not pulled in transitively. Also use explicit null-pointer comparisons for HANDLE/LPVOID checks.
1 parent 009a71f commit feedfb7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Foundation/src/SharedMemory_WIN32.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Poco/Format.h"
2020
#include "Poco/UnicodeConverter.h"
2121
#include "Poco/UnWindows.h"
22+
#include <limits>
2223

2324

2425
namespace Poco {
@@ -51,7 +52,7 @@ SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, Sh
5152
#endif
5253
_memHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, _mode, dwMaxSizeHigh, dwMaxSizeLow, utf16name.c_str());
5354

54-
if (!_memHandle)
55+
if (_memHandle == nullptr)
5556
{
5657
DWORD dwRetVal = GetLastError();
5758
int retVal = static_cast<int>(dwRetVal);
@@ -63,7 +64,7 @@ SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, Sh
6364
}
6465

6566
_memHandle = OpenFileMappingW(PAGE_READONLY, FALSE, utf16name.c_str());
66-
if (!_memHandle)
67+
if (_memHandle == nullptr)
6768
{
6869
dwRetVal = GetLastError();
6970
throw SystemException(Poco::format("Cannot open shared memory object %s [Error %d: %s]",
@@ -128,7 +129,7 @@ void SharedMemoryImpl::map()
128129
if (_mode == PAGE_READWRITE)
129130
access = FILE_MAP_WRITE;
130131
LPVOID addr = MapViewOfFile(_memHandle, access, 0, 0, _size);
131-
if (!addr)
132+
if (addr == nullptr)
132133
{
133134
DWORD dwRetVal = GetLastError();
134135
throw SystemException(format("Cannot map shared memory object %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));

0 commit comments

Comments
 (0)