diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-01-14 20:37:47 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-01-14 20:38:00 +0100 |
| commit | d7007dd3ccbac2fcd4aac4b9d26806c7285e593e (patch) | |
| tree | 020b9d2fefe521ce01b13c57770f252c09ee36f6 /src/core.c | |
| parent | 9c5daf5954b2aa4305357ca5b8d47562671bc9b2 (diff) | |
| download | box64-d7007dd3ccbac2fcd4aac4b9d26806c7285e593e.tar.gz box64-d7007dd3ccbac2fcd4aac4b9d26806c7285e593e.zip | |
Small changes on envv and arv managment
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core.c b/src/core.c index 967af6b6..a6972f8b 100644 --- a/src/core.c +++ b/src/core.c @@ -1388,16 +1388,17 @@ int GatherEnv(char*** dest, char** env, char* prog) { char** p = env; int idx = 0; + int _prog = 0; while(*p) { if(strncmp(*p, "_=", 2)==0) { - // ignore + _prog = 1; } else { (*dest)[idx++] = box_strdup(*p); } ++p; } // add "_=prog" at the end... - if(prog) { + if(_prog && prog) { int l = strlen(prog); char tmp[l+3]; strcpy(tmp, "_="); @@ -1405,7 +1406,7 @@ int GatherEnv(char*** dest, char** env, char* prog) (*dest)[idx++] = box_strdup(tmp); } // and a final NULL - (*dest)[idx++] = 0; + (*dest)[idx++] = NULL; return 0; } @@ -1857,7 +1858,7 @@ static void add_argv(const char* what) { if(!where) where = (box64_wine)?2:1; printf_log(LOG_INFO, "Inserting \"%s\" to the argument %d\n", what, where); - my_context->argv = (char**)box_realloc(my_context->argv, (my_context->argc+1)*sizeof(char*)); + my_context->argv = (char**)box_realloc(my_context->argv, (my_context->argc+1+1)*sizeof(char*)); memmove(my_context->argv+where+1, my_context->argv+where, (my_context->argc-where)*sizeof(char*)); my_context->argv[where] = box_strdup(what); my_context->argc++; @@ -2095,7 +2096,7 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf my_context->envc = CountEnv(environ?environ:env); printf_log(LOG_INFO, "Counted %d Env var\n", my_context->envc); // allocate extra space for new environment variables such as BOX64_PATH - my_context->envv = (char**)box_calloc(my_context->envc+4, sizeof(char*)); + my_context->envv = (char**)box_calloc(my_context->envc+1, sizeof(char*)); path_collection_t ld_preload = {0}; if(getenv("BOX64_LD_PRELOAD")) { |