From 08e2c56ced4e69a50b8235af3e34a52874c2a728 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 25 Feb 2024 19:20:33 +0600 Subject: Replace an instance of MAX_PATH with 32767 ... which is the approximate maximum of Windows API, as documented in https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation Change-Id: I8b10e41d3a8bf85e266f071bdc2eb88eb9403917 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163914 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski --- pyuno/source/loader/pyuno_loader.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pyuno') diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index 0828e9497f51..7c04a376f43e 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -41,16 +41,16 @@ // apparently PATH_MAX is not standard and not defined by MSVC #ifndef PATH_MAX -#ifdef _MAX_PATH +#ifdef _WIN32 +#define PATH_MAX 32767 +#elif defined _MAX_PATH #define PATH_MAX _MAX_PATH -#else -#ifdef MAX_PATH +#elif defined MAX_PATH #define PATH_MAX MAX_PATH #else #error no PATH_MAX #endif #endif -#endif using pyuno::PyRef; using pyuno::NOT_NULL; @@ -120,14 +120,14 @@ static void setPythonHome ( const OUString & pythonHome ) wcsncpy(wide, o3tl::toW(systemPythonHome.getStr()), len + 1); #else OString o = OUStringToOString(systemPythonHome, osl_getThreadTextEncoding()); - size_t len = mbstowcs(wide, o.pData->buffer, PATH_MAX + 1); + size_t len = mbstowcs(wide, o.pData->buffer, std::size(wide)); if(len == size_t(-1)) { PyErr_SetString(PyExc_SystemError, "invalid multibyte sequence in python home path"); return; } #endif - if(len >= PATH_MAX + 1) + if (len >= std::size(wide)) { PyErr_SetString(PyExc_SystemError, "python home path is too long"); return; -- cgit LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author