From cc25aa4cafbbb04cc652c79763c09ab7f584a4d5 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 25 Jul 2018 13:02:18 +0200 Subject: [PATCH] Environment: Do not leave stray ':' in LD_LIBRARY_PATH A empty path segment in LD_LIBRARY_PATH is *not* ignored and treated as '.' IIRC. So make sure to not leave a ':' in first place of LD_LIBRARY_PATH or set an empty LD_LIBRARY_PATH on Linux. Change-Id: I99ec2e333c6c0205334daf14ac6a2373c6e465ad Reviewed-by: Ulf Hermann --- src/libs/utils/environment.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/environment.cpp b/src/libs/utils/environment.cpp index e8e8938739e..1efbc024dd1 100644 --- a/src/libs/utils/environment.cpp +++ b/src/libs/utils/environment.cpp @@ -49,8 +49,10 @@ public: toReplace.append(':'); toReplace.append(lib.path()); - if (ldLibraryPath.startsWith(toReplace)) - set("LD_LIBRARY_PATH", ldLibraryPath.remove(0, toReplace.length())); + if (ldLibraryPath.startsWith(toReplace + ':')) + set("LD_LIBRARY_PATH", ldLibraryPath.remove(0, toReplace.length() + 1)); + else if (ldLibraryPath == toReplace) + unset("LD_LIBRARY_PATH"); } } };