Skip to content

Commit 5d92b5f

Browse files
committed
Avoid a possible infinite recursion in options parsing.
See #502, second issue, for a scenario where this occurs.
1 parent 0560fc2 commit 5d92b5f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/options.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,11 @@ static void mi_option_init(mi_option_desc_t* desc) {
532532
desc->init = INITIALIZED;
533533
}
534534
else {
535-
_mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
535+
/* _mi_warning_message() will itself call mi_option_get() for some options,
536+
* so to avoid a possible infinite recursion it's important to mark the option as
537+
* "initialized" first */
536538
desc->init = DEFAULTED;
539+
_mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
537540
}
538541
}
539542
mi_assert_internal(desc->init != UNINIT);

0 commit comments

Comments
 (0)