From 45c693ad32f0ac9448aa455ee112b0ff13e91755 Mon Sep 17 00:00:00 2001 From: yuanjm Date: Fri, 27 Nov 2020 21:13:53 +0800 Subject: [PATCH] fix(newlib): fix environ is NULL --- components/newlib/src/reent_init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/newlib/src/reent_init.c b/components/newlib/src/reent_init.c index d95e05ac..5ccaf9e4 100644 --- a/components/newlib/src/reent_init.c +++ b/components/newlib/src/reent_init.c @@ -137,8 +137,15 @@ int esp_newlib_init(void) if (!_GLOBAL_REENT->_stdin) goto err_in; + environ = malloc(sizeof(char*)); + if (!environ) + goto err_env; + environ[0] = NULL; + return 0; +err_env: + fclose(_GLOBAL_REENT->_stdin); err_in: fclose(_GLOBAL_REENT->_stderr); err_fail: