summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/dtrans
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-12-08 16:38:44 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-12-10 16:27:35 +0100
commit4f0c70fb5554325e0cc2129741175bf07de22029 (patch)
treef6fc98fa67183594f1173c089979cc5f2ac8ff4a /vcl/unx/generic/dtrans
parent65b1152f5cc67067b66945d8bb2db009a3cb554e (diff)
Avoid calling OString ctor with null pointer
...in preparation of potential future changes from using OString to using std::string_view, where OString has an undocumented feature of allowing construction from a null pointer. This is mostly the result of a manual audit of potentially problematic getenv calls across the code base. But there can be other problematic places too, like the xmlGetProp call in tools/source/xml/XmlWalker.cxx. To identify those, rtl_{string,uString}_newFromStr aborts now in non-production debug builds when a null pointer is passed(and all places that hit with a full `make check screenshot` have been addressed here). Once we are confident that all problematic places have been identified, we should drop support for the undocumented feature (see the TODO in sal/rtl/strtmpl.cxx). Change-Id: I595cc6d4f1cda74add2a3db171323f817d362b08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107430 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/unx/generic/dtrans')
-rw-r--r--vcl/unx/generic/dtrans/X11_selection.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx
index ce98fcbd09f5..b9b96f9e514d 100644
--- a/vcl/unx/generic/dtrans/X11_selection.cxx
+++ b/vcl/unx/generic/dtrans/X11_selection.cxx
@@ -675,7 +675,9 @@ SelectionManager& SelectionManager::get( const OUString& rDisplayName )
OUString aDisplayName( rDisplayName );
if( aDisplayName.isEmpty() )
- aDisplayName = OStringToOUString( getenv( "DISPLAY" ), RTL_TEXTENCODING_ISO_8859_1 );
+ if (auto const env = getenv( "DISPLAY" )) {
+ aDisplayName = OStringToOUString( env, RTL_TEXTENCODING_ISO_8859_1 );
+ }
SelectionManager* pInstance = nullptr;
std::unordered_map< OUString, SelectionManager* >::iterator it = getInstances().find( aDisplayName );