mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-27 13:33:18 +08:00
put a bound on the environment search
This commit is contained in:
parent
45974efdb7
commit
4f020e5da4
@ -439,9 +439,9 @@ static bool mi_getenv(const char* name, char* result, size_t result_size) {
|
|||||||
if (len == 0) return false;
|
if (len == 0) return false;
|
||||||
char** env = mi_get_environ();
|
char** env = mi_get_environ();
|
||||||
if (env == NULL) return false;
|
if (env == NULL) return false;
|
||||||
// compare all entries
|
// compare up to 256 entries
|
||||||
for (; *env != NULL; env++) {
|
for (int i = 0; i < 256 && env[i] != NULL; i++) {
|
||||||
const char* s = *env;
|
const char* s = env[i];
|
||||||
if (mi_strnicmp(name, s, len) == 0 && s[len] == '=') { // case insensitive
|
if (mi_strnicmp(name, s, len) == 0 && s[len] == '=') { // case insensitive
|
||||||
// found it
|
// found it
|
||||||
mi_strlcpy(result, s + len + 1, result_size);
|
mi_strlcpy(result, s + len + 1, result_size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user