summaryrefslogtreecommitdiff
path: root/sal/osl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-02-16 20:57:05 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-02-16 22:16:04 +0100
commitc8976bdfdfa361fec9e1e5ff342094e409981fad (patch)
treedcda31038ff2cef4916f38d11eda3a8cb3dbb3fc /sal/osl
parent3d25de5440d310cef6c0c256c64472a928e4cb90 (diff)
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@redhat.com>
Diffstat (limited to 'sal/osl')
-rw-r--r--sal/osl/unx/module.cxx28
1 files changed, 14 insertions, 14 deletions
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);