X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fenvironment.cpp;h=d6be70d54a6b1eb1db87d3f368d9fc1d2ed49499;hp=9c0f53e47a69a3ade13f32da7fa66e492526bfab;hb=aa8c5aec5c7f578b977abb4322e2322df8edd662;hpb=5887d2c065503465a3c6ef422b0055b4ace485bd diff --git a/radiant/environment.cpp b/radiant/environment.cpp index 9c0f53e4..d6be70d5 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -224,22 +224,23 @@ const char* LINK_NAME = #endif ; -/// brief Returns the filename of the executable belonging to the current process, or 0 if not found. +/// brief Returns the filename of the executable belonging to the current process, or empty string if not found. char const* getexename( char *buf ){ /* Now read the symbolic link */ - int ret = readlink( LINK_NAME, buf, PATH_MAX ); + const int ret = readlink( LINK_NAME, buf, PATH_MAX ); if ( ret == -1 ) { globalOutputStream() << "getexename: falling back to argv[0]: " << makeQuoted( g_argv[0] ); - const char* path = realpath( g_argv[0], buf ); - if ( path == 0 ) { + if( realpath( g_argv[0], buf ) == 0 ) { /* In case of an error, leave the handling up to the caller */ - return ""; + *buf = '\0'; } } + else { + /* Ensure proper NUL termination */ + buf[ret] = 0; + } - /* Ensure proper NUL termination */ - buf[ret] = 0; return buf; }