]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix module_format_fun_env when dynlib_addr fails
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Nov 2015 07:43:43 +0000 (23:43 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Nov 2015 07:44:10 +0000 (23:44 -0800)
* src/emacs-module.c (module_format_fun_env):
exprintf doesn’t support %p, so use %x.  Reported by Eli Zaretskii in:
http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg02122.html

src/emacs-module.c

index 11aefc31359095a7a122f2fd7beb4ffff58837cb..1388e5348bb2e6090134d2008f0b5969b9219045 100644 (file)
@@ -1035,15 +1035,15 @@ module_format_fun_env (const struct module_fun_env *env)
 {
   /* Try to print a function name if possible.  */
   const char *path, *sym;
-  char buffer[256];
+  static char const noaddr_format[] = "#<module function at %p>";
+  char buffer[sizeof noaddr_format + INT_STRLEN_BOUND (intptr_t) + 256];
   char *buf = buffer;
   ptrdiff_t bufsize = sizeof buffer;
   ptrdiff_t size
     = (dynlib_addr (env->subr, &path, &sym)
        ? exprintf (&buf, &bufsize, buffer, -1,
                   "#<module function %s from %s>", sym, path)
-       : exprintf (&buf, &bufsize, buffer, -1,
-                  "#<module function at %p>", env->subr));
+       : sprintf (buffer, noaddr_format, env->subr));
   Lisp_Object unibyte_result = make_unibyte_string (buffer, size);
   if (buf != buffer)
     xfree (buf);