mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
libc: initialize the environ pointer before Libc::construct
Setting the global environ pointer to NULL prevents getenv surprises when using libc without the POSIX wrapper. Fix #2312
This commit is contained in:
parent
ec007c0f27
commit
10ed7b38d4
@ -37,6 +37,7 @@
|
||||
#include "libc_init.h"
|
||||
#include "task.h"
|
||||
|
||||
extern char **environ;
|
||||
|
||||
namespace Libc {
|
||||
class Env_implementation;
|
||||
@ -844,6 +845,10 @@ Genode::size_t Component::stack_size() { return Libc::Component::stack_size(); }
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
/* initialize the global pointer to environment variables */
|
||||
static char *null_env = nullptr;
|
||||
if (!environ) environ = &null_env;
|
||||
|
||||
/* pass Genode::Env to libc subsystems that depend on it */
|
||||
Libc::init_mem_alloc(env);
|
||||
Libc::init_dl(env);
|
||||
|
Loading…
Reference in New Issue
Block a user