diff options
-rw-r--r-- | crawl-ref/source/initfile.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 5ea6dc449c..7d7e9f033c 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -3459,7 +3459,10 @@ std::string find_executable_path() #if defined ( _MSC_VER ) GetModuleFileName ( NULL, tempPath, sizeof(tempPath) ); #elif defined ( __linux__ ) - readlink ( "/proc/self/exe", tempPath, sizeof(tempPath) ); + const ssize_t rsize = + readlink("/proc/self/exe", tempPath, sizeof(tempPath) - 1); + if (rsize > 0) + tempPath[rsize] = 0; #elif defined ( __MACH__ ) strncpy ( tempPath, NXArgv[0], sizeof(tempPath) ); #else |