emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 005d834: Avoid segfaults on MS-Windows in enexec'ed


From: Eli Zaretskii
Subject: [Emacs-diffs] master 005d834: Avoid segfaults on MS-Windows in enexec'ed Emacs
Date: Thu, 7 Feb 2019 10:24:55 -0500 (EST)

branch: master
commit 005d8346b8cc9ca7675890f085ce34c56ab2723a
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid segfaults on MS-Windows in enexec'ed Emacs
    
    * src/emacs.c (main) [WINDOWSNT]: Fix logic of using dynamic
    heap in unexec case.  (Bug#34277)
---
 src/emacs.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/emacs.c b/src/emacs.c
index 9277399..c5163db 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -914,17 +914,23 @@ main (int argc, char **argv)
      happens.  This relies on the static heap being needed only in
      temacs and only if we are going to dump with unexec.  */
   bool use_dynamic_heap = false;
-  char *temacs_str = strstr (argv[0], "temacs");
-  if (temacs
-      && temacs_str != NULL
-      && (temacs_str == argv[0] || IS_DIRECTORY_SEP (temacs_str[-1])))
+  if (temacs)
     {
-      /* Note that gflags are set at this point only if we have been
-        called with the --temacs=METHOD option.  We assume here that
-        temacs is always called that way, otherwise the functions
-        that rely on gflags, like will_dump_with_pdumper_p below,
-        will not do their job.  */
-      use_dynamic_heap = will_dump_with_pdumper_p ();
+      char *temacs_str = NULL, *p;
+      for (p = argv[0]; (p = strstr (p, "temacs")) != NULL; p++)
+       temacs_str = p;
+      if (temacs_str != NULL
+         && (temacs_str == argv[0] || IS_DIRECTORY_SEP (temacs_str[-1])))
+       {
+         /* Note that gflags are set at this point only if we have been
+            called with the --temacs=METHOD option.  We assume here that
+            temacs is always called that way, otherwise the functions
+            that rely on gflags, like will_dump_with_pdumper_p below,
+            will not do their job.  */
+         use_dynamic_heap = will_dump_with_pdumper_p ();
+       }
+      else
+       use_dynamic_heap = true;
     }
   else
     use_dynamic_heap = true;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]