about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-08-18 08:55:03 +0200
committerGitHub <noreply@github.com>2023-08-18 08:55:03 +0200
commit2bb42ae9a9dd0a06f3128938a203818b86de8052 (patch)
tree820276bcdd2ea35538b94d523f364ced3fb90d63 /src
parent47057f076a04693fe2f01dcb9abcbab2eb72a933 (diff)
parent54ce282b8cb518ce4498863fbfcf0f6b831617b8 (diff)
downloadbox64-2bb42ae9a9dd0a06f3128938a203818b86de8052.tar.gz
box64-2bb42ae9a9dd0a06f3128938a203818b86de8052.zip
Merge pull request #937 from kaixindeken/main
Fixed wild pointer error for my_context->elfs while calling my___libc_start_main
Diffstat (limited to 'src')
-rw-r--r--src/emu/x64run_private.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c
index e4213371..671034b6 100644
--- a/src/emu/x64run_private.c
+++ b/src/emu/x64run_private.c
@@ -53,9 +53,13 @@ int32_t EXPORT my___libc_start_main(x64emu_t* emu, int *(main) (int, char * *, c
         SetRBP(emu, old_rbp);
         emu->quit = 0;
     } else {
-        RunElfInit(my_context->elfs[0], emu);
+        if(my_context->elfs[0]) {
+            RunElfInit(my_context->elfs[0], emu);
+        }
+    }
+    if(my_context->elfs[0]) {
+        MarkElfInitDone(my_context->elfs[0]);
     }
-    MarkElfInitDone(my_context->elfs[0]);
     printf_log(LOG_DEBUG, "Transfert to main(%d, %p, %p)=>%p from __libc_start_main\n", my_context->argc, my_context->argv, my_context->envv, main);
     // call main and finish
     Push64(emu, GetRBP(emu));   // set frame pointer