This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Module::CoreList for Perl 5.19.5
[perl5.git] / miniperlmain.c
index 7b96e48..a1ef2f1 100644 (file)
@@ -40,9 +40,8 @@
 #endif
 #endif
 
-
-#include "EXTERN.h"
 #define PERL_IN_MINIPERLMAIN_C
+#include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
 
@@ -67,12 +66,11 @@ int
 main(int argc, char **argv, char **env)
 #endif
 {
-    dVAR;
     int exitstatus, i;
 #ifdef PERL_GLOBAL_STRUCT
-    struct perl_vars *plvarsp = init_global_struct();
+    struct perl_vars *my_vars = init_global_struct();
 #  ifdef PERL_GLOBAL_STRUCT_PRIVATE
-    my_vars = my_plvarsp = plvarsp;
+    my_plvarsp = my_vars;
 #  endif
 #endif /* PERL_GLOBAL_STRUCT */
 #ifndef NO_ENV_ARRAY_IN_MAIN
@@ -148,7 +146,13 @@ main(int argc, char **argv, char **env)
     PERL_SYS_TERM();
 
 #ifdef PERL_GLOBAL_STRUCT
-    free_global_struct(plvarsp);
+    free_global_struct(my_vars);
+#  ifdef PERL_GLOBAL_STRUCT_PRIVATE
+    my_plvarsp = NULL;
+    /* Remember, functions registered with atexit() can run after this point,
+       and may access "global" variables, and hence end up calling
+       Perl_GetVarsPrivate()  */
+#endif
 #endif /* PERL_GLOBAL_STRUCT */
 
     exit(exitstatus);