]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix MS-Windows build following last change
authorEli Zaretskii <eliz@gnu.org>
Wed, 14 Apr 2021 14:28:19 +0000 (17:28 +0300)
committerEli Zaretskii <eliz@gnu.org>
Wed, 14 Apr 2021 14:28:19 +0000 (17:28 +0300)
* src/emacs.c (real_filename) [WINDOWSNT]: Fix off-by-one error
when allocating storage for a file name.

src/emacs.c

index f0d75f5c20d9c07dcc02a3ccc3daa00eacea9b4f..a2565645c6ce9deea701548aa9f444dd63755498 100644 (file)
@@ -450,16 +450,14 @@ real_filename (char *filename)
 #ifdef WINDOWSNT
   /* w32_my_exename resolves symlinks internally, so no need to
      call realpath.  */
-  real_name = xmalloc (strlen (filename));
-  strcpy (real_name, filename);
-  return real_name;
+  real_name = xstrdup (filename);
 #else
   real_name = realpath (filename, NULL);
   if (!real_name)
     fatal ("could not resolve realpath of \"%s\": %s",
           filename, strerror (errno));
-  return real_name;
 #endif
+  return real_name;
 }
 
 /* Set `invocation-name' `invocation-directory'.  */