pyuno/source/loader/pyuno_loader.cxx |   12 ++++++------
 pyuno/zipcore/python.cxx             |    6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 08e2c56ced4e69a50b8235af3e34a52874c2a728
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Feb 25 19:20:33 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Feb 26 03:20:17 2024 +0100

    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.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

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;
commit 7411caca669a178f3b8b0eb99a65f24e3e601215
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Feb 25 19:19:05 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Feb 26 03:20:04 2024 +0100

    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: I22aecd9b9e1423b74b61985cad11bb3c194f2bdc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163913
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/pyuno/zipcore/python.cxx b/pyuno/zipcore/python.cxx
index b4f3149be128..93152fd9970c 100644
--- a/pyuno/zipcore/python.cxx
+++ b/pyuno/zipcore/python.cxx
@@ -64,9 +64,9 @@ static wchar_t * encode(wchar_t * buffer, wchar_t const * 
text) {
 }
 
 int wmain(int argc, wchar_t ** argv, wchar_t **) {
-    wchar_t path[MAX_PATH];
-    DWORD n = GetModuleFileNameW(nullptr, path, MAX_PATH);
-    if (n == 0 || n >= MAX_PATH) {
+    wchar_t path[32767];
+    DWORD n = GetModuleFileNameW(nullptr, path, std::size(path));
+    if (n == 0 || n >= std::size(path)) {
         exit(EXIT_FAILURE);
     }
     wchar_t * pathEnd = tools::filename(path);

Reply via email to