Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45c693a

Browse files
committed
fix(newlib): fix environ is NULL
1 parent 61c3c11 commit 45c693a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

components/newlib/src/reent_init.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,15 @@ int esp_newlib_init(void)
137137
if (!_GLOBAL_REENT->_stdin)
138138
goto err_in;
139139

140+
environ = malloc(sizeof(char*));
141+
if (!environ)
142+
goto err_env;
143+
environ[0] = NULL;
144+
140145
return 0;
141146

147+
err_env:
148+
fclose(_GLOBAL_REENT->_stdin);
142149
err_in:
143150
fclose(_GLOBAL_REENT->_stderr);
144151
err_fail:

0 commit comments

Comments
 (0)