[Libreoffice-commits] core.git: sal/osl
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 16 21:16:51 UTC 2021
sal/osl/unx/module.cxx | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
New commits:
commit c8976bdfdfa361fec9e1e5ff342094e409981fad
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Feb 16 20:57:05 2021 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Feb 16 22:16:04 2021 +0100
tdf#137208 Assume that dladdr provides an absolute pathname
3dfb38a45d6495d357c3359b5b02cde871df6f67 "added getUrlFromAddress (#88338#)" had
introduced the call to osl_getAbsoluteFileURL for no documented reason, but it
looks unlikely that any relevant implementation of dladdr (as called by
getModulePathFromAddress; and where dladdr is a non-POSIX extension on the
various platforms) would provide pathnames that are relative to the process's
CWD.
(Instead, add a check whether osl_getFileURLFromSystemPath succeeds.)
Change-Id: If291e9fdf63fc3f42ba7c7e3138d7db5328ed165
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111004
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx
index 7669c047a7a3..72653a997f92 100644
--- a/sal/osl/unx/module.cxx
+++ b/sal/osl/unx/module.cxx
@@ -298,27 +298,27 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibr
rtl_String * path = nullptr;
if (getModulePathFromAddress(addr, &path))
{
- rtl_uString * workDir = nullptr;
- osl_getProcessWorkingDir(&workDir);
- if (workDir)
+ rtl_string2UString(ppLibraryUrl,
+ path->buffer,
+ path->length,
+ osl_getThreadTextEncoding(),
+ OSTRING_TO_OUSTRING_CVTFLAGS);
+
+ SAL_WARN_IF(
+ *ppLibraryUrl == nullptr, "sal.osl", "rtl_string2UString failed");
+ auto const e = osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl);
+ if (e == osl_File_E_None)
{
- rtl_string2UString(ppLibraryUrl,
- path->buffer,
- path->length,
- osl_getThreadTextEncoding(),
- OSTRING_TO_OUSTRING_CVTFLAGS);
-
- SAL_WARN_IF(
- *ppLibraryUrl == nullptr, "sal.osl", "rtl_string2UString failed");
- osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl);
- osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl);
SAL_INFO("sal.osl", "osl_getModuleURLFromAddress(" << addr << ") => " << OUString(*ppLibraryUrl));
- rtl_uString_release(workDir);
result = true;
}
else
{
+ SAL_WARN(
+ "sal.osl",
+ "osl_getModuleURLFromAddress(" << addr << "), osl_getFileURLFromSystemPath("
+ << OUString::unacquired(ppLibraryUrl) << ") failed with " << e);
result = false;
}
rtl_string_release(path);
More information about the Libreoffice-commits
mailing list