diff options
author | 2016-12-01 12:36:33 +0000 | |
---|---|---|
committer | 2016-12-01 13:31:31 +0000 | |
commit | ec1cc8fa6cbdbba6e2689d3a814e095bb068e15e (patch) | |
tree | 7d8ab838d697a151ebb31f9630b12e204d2ede13 | |
parent | b0cc87feb4bd490458185d62feca2a9b96f4c498 (diff) |
Gracefully handle unset JAVA_HOME
getenv("JAVA_HOME") may return a null pointer; in this case, the
corresponding string is in a state where calling .empty() segfaults.
However, there is a legimitate use case for JAVA_HOME not being set;
in fact, the default "/usr/local/openjdk8" is usually fine on FreeBSD.
--
Change-Id: I4a2ad7d19ef38c79e9f1c62b0f8041e434203c7f
Reviewed-on: https://cr.bazel.build/7590
MOS_MIGRATED_REVID=140716748
-rw-r--r-- | src/main/cpp/blaze_util_freebsd.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/cpp/blaze_util_freebsd.cc b/src/main/cpp/blaze_util_freebsd.cc index f1177b2192..22c5dd1418 100644 --- a/src/main/cpp/blaze_util_freebsd.cc +++ b/src/main/cpp/blaze_util_freebsd.cc @@ -145,7 +145,7 @@ bool IsSharedLibrary(const string &filename) { string GetDefaultHostJavabase() { // if JAVA_HOME is defined, then use it as default. - string javahome = getenv("JAVA_HOME"); + string javahome = GetEnv("JAVA_HOME"); return !javahome.empty() ? javahome : "/usr/local/openjdk8"; } |