From 95dd6bb08038e31515568943dcfae13afac8ff70 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 14 Apr 2021 17:28:19 +0300 Subject: [PATCH] Fix MS-Windows build following last change * src/emacs.c (real_filename) [WINDOWSNT]: Fix off-by-one error when allocating storage for a file name. --- src/emacs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index f0d75f5c20d..a2565645c6c 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -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'. */ -- 2.39.5