summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-02-25 19:20:33 +0600
committerMike Kaganski <mike.kaganski@collabora.com>2024-02-26 03:20:17 +0100
commit08e2c56ced4e69a50b8235af3e34a52874c2a728 (patch)
tree1ad2fbb6e137f60ca0bba48d4e3c5eccf59432e9 /pyuno
parent7411caca669a178f3b8b0eb99a65f24e3e601215 (diff)
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 <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/loader/pyuno_loader.cxx12
1 files changed, 6 insertions, 6 deletions
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;