sal/osl/unx/system.cxx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
New commits: commit fa1b6aa517966991ce1a1d0135bd5dfae331ab9a Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sat Feb 10 19:11:25 2024 -0500 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Sun Feb 11 13:39:10 2024 +0100 tdf#155710 handle conversion failures due to non-UTF8 strings Windows and Linux paths can be passed as parameters to this function and those paths may not always be UTF8 encoded like macOS paths. Change-Id: I83f5ab491d3c0ddd938e512fbab3213af9ea16fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163223 Tested-by: Jenkins Reviewed-by: Patrick Luby <guibomac...@gmail.com> diff --git a/sal/osl/unx/system.cxx b/sal/osl/unx/system.cxx index f19bd7053100..eba4fe01c6c5 100644 --- a/sal/osl/unx/system.cxx +++ b/sal/osl/unx/system.cxx @@ -48,11 +48,6 @@ int macxp_resolveAlias(char *path, int buflen) (void) buflen; return 0; #else - CFStringRef cfpath; - CFURLRef cfurl; - CFErrorRef cferror; - CFDataRef cfbookmark; - // Don't even try anything for files inside the app bundle. Just a // waste of time. @@ -74,12 +69,19 @@ int macxp_resolveAlias(char *path, int buflen) if ( unprocessedPath ) *unprocessedPath = ' - cfpath = CFStringCreateWithCString( nullptr, path, kCFStringEncodingUTF8 ); - cfurl = CFURLCreateWithFileSystemPath( nullptr, cfpath, kCFURLPOSIXPathStyle, false ); - CFRelease( cfpath ); - cferror = nullptr; - cfbookmark = CFURLCreateBookmarkDataFromFile( nullptr, cfurl, &cferror ); - CFRelease( cfurl ); + // tdf#155710 handle conversion failures due to non-UTF8 strings + // Windows and Linux paths can be passed as parameters to this function + // and those paths may not always be UTF8 encoded like macOS paths. + CFStringRef cfpath = CFStringCreateWithCString( nullptr, path, kCFStringEncodingUTF8 ); + CFErrorRef cferror = nullptr; + CFDataRef cfbookmark = nullptr; + if (cfpath) + { + CFURLRef cfurl = CFURLCreateWithFileSystemPath( nullptr, cfpath, kCFURLPOSIXPathStyle, false ); + CFRelease( cfpath ); + cfbookmark = CFURLCreateBookmarkDataFromFile( nullptr, cfurl, &cferror ); + CFRelease( cfurl ); + } if ( cfbookmark == nullptr ) { @@ -91,7 +93,7 @@ int macxp_resolveAlias(char *path, int buflen) else { Boolean isStale; - cfurl = CFURLCreateByResolvingBookmarkData( nullptr, cfbookmark, kCFBookmarkResolutionWithoutUIMask, + CFURLRef cfurl = CFURLCreateByResolvingBookmarkData( nullptr, cfbookmark, kCFBookmarkResolutionWithoutUIMask, nullptr, nullptr, &isStale, &cferror ); CFRelease( cfbookmark ); if ( cfurl == nullptr )