From 4f020e5da4552fb254ce35db1adad5c63d68d09e Mon Sep 17 00:00:00 2001 From: daan Date: Tue, 5 May 2020 20:19:20 -0700 Subject: [PATCH] put a bound on the environment search --- src/options.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/options.c b/src/options.c index 9714d264..f29b387c 100644 --- a/src/options.c +++ b/src/options.c @@ -439,9 +439,9 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) { if (len == 0) return false; char** env = mi_get_environ(); if (env == NULL) return false; - // compare all entries - for (; *env != NULL; env++) { - const char* s = *env; + // compare up to 256 entries + for (int i = 0; i < 256 && env[i] != NULL; i++) { + const char* s = env[i]; if (mi_strnicmp(name, s, len) == 0 && s[len] == '=') { // case insensitive // found it mi_strlcpy(result, s + len + 1, result_size);