From 08c3dbe2ba6645fb5274eb428a8bde81b8b18b00 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Mon, 14 May 2018 15:50:55 +0800 Subject: [PATCH] feat(newlib): Initialize environ --- components/newlib/newlib/port/esp_newlib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/newlib/newlib/port/esp_newlib.c b/components/newlib/newlib/port/esp_newlib.c index 3425de64..f93e32cf 100644 --- a/components/newlib/newlib/port/esp_newlib.c +++ b/components/newlib/newlib/port/esp_newlib.c @@ -14,7 +14,9 @@ #include #include +#include #include +#include /* * @brief Initialize global and thread's private reent object data. We add this instead of @@ -57,8 +59,15 @@ int esp_newlib_init(void) if (!_GLOBAL_REENT->_stdin) goto err_in; + environ = malloc(sizeof(char*)); + if (!environ) + goto environ_in; + environ[0] = NULL; + return 0; +environ_in: + fclose(_GLOBAL_REENT->_stdin); err_in: fclose(_GLOBAL_REENT->_stderr); err_fail: