在 2018年06月14日 18:26, Martin Storsjo 写道:
> The _NSGetExecutablePath function is undocumented, but in practice,
> on return, the bufsize parameter has the same value as it had on
> entry; the full buffer size.
> 
> This avoids accidentally doing null termination after the end of the
> allocated buffer on macOS.
> 
> Signed-off-by: Martin Storsjo <[email protected]>
> ---
>  mingw-w64-tools/widl/src/pathtools.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mingw-w64-tools/widl/src/pathtools.c 
> b/mingw-w64-tools/widl/src/pathtools.c
> index 0378ebdd..0ccc33e8 100644
> --- a/mingw-w64-tools/widl/src/pathtools.c
> +++ b/mingw-w64-tools/widl/src/pathtools.c
> @@ -293,7 +293,7 @@ get_executable_path(char const * argv0, char * result, 
> ssize_t max_size)
>      uint32_t bufsize = (uint32_t)max_size;
>      if (_NSGetExecutablePath(system_result, &bufsize) == 0)
>      {
> -      system_result_size = (ssize_t)bufsize;
> +      system_result_size = strlen (system_result);
>      }
>  #elif defined(_WIN32)
>      unsigned long bufsize = (unsigned long)max_size;
> 

If you can confirm this works expectedly on macOS, I am fine with it.

-- 
Best regards,
LH_Mouse
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to