summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--idl/source/prj/command.cxx3
-rw-r--r--sal/osl/w32/socket.cxx6
-rw-r--r--sal/qa/osl/file/osl_File.cxx4
-rw-r--r--sal/rtl/strtmpl.cxx10
-rw-r--r--test/source/screenshot_test.cxx4
-rw-r--r--tools/source/xml/XmlWalker.cxx3
-rw-r--r--vcl/headless/svpprn.cxx4
-rw-r--r--vcl/qt5/Qt5Instance_Print.cxx5
-rw-r--r--vcl/unx/generic/dtrans/X11_selection.cxx4
9 files changed, 34 insertions, 9 deletions
diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx
index 35f6e6c28e87..29b01d11219a 100644
--- a/idl/source/prj/command.cxx
+++ b/idl/source/prj/command.cxx
@@ -277,7 +277,8 @@ SvCommand::SvCommand( int argc, char ** argv )
aList.clear();
- OString aInc(getenv("INCLUDE"));
+ auto const env = getenv("INCLUDE");
+ OString aInc(env == nullptr ? "" : env);
// append include environment variable
if( aInc.getLength() )
{
diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx
index ba96cc5ed838..9e819beaa61f 100644
--- a/sal/osl/w32/socket.cxx
+++ b/sal/osl/w32/socket.cxx
@@ -512,7 +512,11 @@ oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname)
{
pRet = static_cast<oslHostAddr>(
rtl_allocateZeroMemory(sizeof(struct oslHostAddrImpl)));
- rtl_uString_newFromStr(&pRet->pHostName, o3tl::toU(pIter->ai_canonname));
+ if (pIter->ai_canonname == nullptr) {
+ rtl_uString_new(&pRet->pHostName);
+ } else {
+ rtl_uString_newFromStr(&pRet->pHostName, o3tl::toU(pIter->ai_canonname));
+ }
pRet->pSockAddr = createSocketAddr();
memcpy(& pRet->pSockAddr->m_sockaddr,
pIter->ai_addr, pIter->ai_addrlen);
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 42c7a18a4f11..23b5398ac65a 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -931,7 +931,7 @@ namespace osl_FileBase
OString sURL("file://~/tmp");
char* home_path;
home_path = getenv("HOME");
- OString expResult(home_path);
+ OString expResult(home_path ? home_path : "");
expResult += "/tmp";
checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, expResult);
#endif
@@ -1009,7 +1009,7 @@ namespace osl_FileBase
OString sSysPath("~/tmp");
char* home_path;
home_path = getenv("HOME");
- OString expResult(home_path);
+ OString expResult(home_path ? home_path : "");
expResult = "file://"+ expResult + "/tmp";
checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, expResult);
checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "~/tmp");
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index bf58db0ba037..2292321f747b 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -24,6 +24,7 @@
#include <algorithm>
#include <cassert>
+#include <cstdlib>
#include <limits>
#include <cstring>
@@ -1324,6 +1325,15 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromStr )( IMPL_RTL_STRINGDATA** ppThis,
IMPL_RTL_STRINGDATA* pOrg;
sal_Int32 nLen;
+#if OSL_DEBUG_LEVEL > 0
+ //TODO: For now, only abort in non-production debug builds; once all places that rely on the
+ // undocumented newFromStr behavior of treating a null pCharStr like an empty string have been
+ // found and fixed, drop support for that behavior and turn this into a general assert:
+ if (pCharStr == nullptr) {
+ std::abort();
+ }
+#endif
+
if ( pCharStr )
{
nLen = IMPL_RTL_STRNAME( getLength )( pCharStr );
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx
index 3b91038fda48..3466886b597d 100644
--- a/test/source/screenshot_test.cxx
+++ b/test/source/screenshot_test.cxx
@@ -47,7 +47,9 @@ ScreenshotTest::ScreenshotTest()
, maParent(nullptr, "vcl/ui/screenshotparent.ui", "ScreenShot")
, mxParentWidget(maParent.getDialog()->weld_content_area())
{
- maCurrentLanguage = OUString::fromUtf8(getenv("LO_TEST_LOCALE"));
+ if (auto const env = getenv("LO_TEST_LOCALE")) {
+ maCurrentLanguage = OUString::fromUtf8(env);
+ }
}
ScreenshotTest::~ScreenshotTest()
diff --git a/tools/source/xml/XmlWalker.cxx b/tools/source/xml/XmlWalker.cxx
index b21c22335018..219bf10c8bb5 100644
--- a/tools/source/xml/XmlWalker.cxx
+++ b/tools/source/xml/XmlWalker.cxx
@@ -90,7 +90,8 @@ OString XmlWalker::attribute(const OString& sName)
{
xmlChar* xmlName = xmlCharStrdup(sName.getStr());
xmlChar* xmlAttribute = xmlGetProp(mpImpl->mpCurrent, xmlName);
- OString aAttributeContent(reinterpret_cast<const char*>(xmlAttribute));
+ OString aAttributeContent(
+ xmlAttribute == nullptr ? "" : reinterpret_cast<const char*>(xmlAttribute));
xmlFree(xmlAttribute);
xmlFree(xmlName);
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index 7ecb59f8c0b2..36c9d5398739 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -50,7 +50,9 @@ static OUString getPdfDir( const PrinterInfo& rInfo )
sal_Int32 nPos = 0;
aDir = aToken.getToken( 1, '=', nPos );
if( aDir.isEmpty() )
- aDir = OStringToOUString( OString( getenv( "HOME" ) ), osl_getThreadTextEncoding() );
+ if (auto const env = getenv( "HOME" )) {
+ aDir = OStringToOUString( OString( env ), osl_getThreadTextEncoding() );
+ }
break;
}
}
diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx
index 3670eb67e4cd..1052907ba1ac 100644
--- a/vcl/qt5/Qt5Instance_Print.cxx
+++ b/vcl/qt5/Qt5Instance_Print.cxx
@@ -50,7 +50,10 @@ static OUString getPdfDir(const PrinterInfo& rInfo)
sal_Int32 nPos = 0;
aDir = aToken.getToken(1, '=', nPos);
if (aDir.isEmpty())
- aDir = OStringToOUString(OString(getenv("HOME")), osl_getThreadTextEncoding());
+ if (auto const env = getenv("HOME"))
+ {
+ aDir = OStringToOUString(OString(env), osl_getThreadTextEncoding());
+ }
break;
}
}
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 );