From 15c121ee0b5cbe005548eeba09dd54b145b2e258 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sat, 30 May 2020 11:13:38 +0100 Subject: [PATCH] * Avoid calling Ffile_exists_p too early Being quite early in startup initialization is better not to rely on Ffile_exists_p, this call Ffile_expand and not all the necessary initialization already happened. * src/pdumper.c (dump_do_dump_relocation): Use fopen instead of Ffile_exists_p. --- src/pdumper.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/pdumper.c b/src/pdumper.c index b40a29c02ac..19dbacca896 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5301,17 +5301,25 @@ dump_do_dump_relocation (const uintptr_t dump_base, if (!CONSP (comp_u->file)) error ("Trying to load incoherent dumped .eln"); + /* Check just once if this is a local build or Emacs was installed. */ if (installation_state == UNKNOWN) - /* Check just once if is a local build or Emacs got installed. */ - installation_state = - NILP (Ffile_exists_p (concat2 (Vinvocation_directory, - XCAR (comp_u->file)))) - ? LOCAL_BUILD : INSTALLED; + { + char *fname = SSDATA (concat2 (Vinvocation_directory, + XCAR (comp_u->file))); + FILE *file; + if ((file = fopen (fname, "r"))) + { + fclose (file); + installation_state = INSTALLED; + } + else + installation_state = LOCAL_BUILD; + } comp_u->file = concat2 (Vinvocation_directory, - installation_state == LOCAL_BUILD - ? XCDR (comp_u->file) : XCAR (comp_u->file)); + installation_state == INSTALLED + ? XCAR (comp_u->file) : XCDR (comp_u->file)); #ifdef WINDOWSNT comp_u->cfile = xlispstrdup (comp_u->file); #endif -- 2.39.5