Skip to content

Commit 7748f65

Browse files
committed
Restrict use of ImageJ.cfg
Only use the Java command (and thus JRE) specified in the ImageJ.cfg if: 1) We are running in legacy mode 2) The specified Java command actually exists
1 parent 3075076 commit 7748f65

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/c/config.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void parse_legacy_config(struct string *jvm_options)
5151

5252
debug("ImageJ.cfg:%d: %.*s", line, (int)(eol - p), p);
5353

54-
if (line == 2) {
54+
if (line == 2 && legacy_mode) {
5555
int jre_len = -1;
5656
#ifdef WIN32
5757
if (!suffixcmp(p, eol - p, "\\bin\\javaw.exe"))
@@ -68,7 +68,13 @@ void parse_legacy_config(struct string *jvm_options)
6868
#endif
6969
if (jre_len > 0) {
7070
p[jre_len] = '\0';
71-
set_legacy_jre_path(p);
71+
const struct string *jre_dir = string_copy(p);
72+
if (file_exists(jre_dir->buffer)) {
73+
set_legacy_jre_path(p);
74+
} else {
75+
debug("ImageJ.cfg points to invalid java: %s", p);
76+
}
77+
string_release(jre_dir);
7278
}
7379
}
7480
else if (line == 3) {

0 commit comments

Comments
 (0)