From ddbaf03d723a633d53fa442c2f802f7ad164dd6c Mon Sep 17 00:00:00 2001 From: Timothee 'TTimo' Besset Date: Sun, 23 Apr 2023 23:08:28 -0500 Subject: [PATCH] fix usage of realpath --- radiant/missing.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/radiant/missing.cpp b/radiant/missing.cpp index 9f88c88f..fa6bfddf 100644 --- a/radiant/missing.cpp +++ b/radiant/missing.cpp @@ -54,9 +54,13 @@ bool radCopyFile( const char *lpExistingFileName, const char *lpNewFileName, boo int l; bool ret = false; char realsrc[PATH_MAX], realdest[PATH_MAX]; + memset( realsrc, 0, sizeof(realsrc) ); + memset( realdest, 0, sizeof(realdest) ); - realpath( lpExistingFileName, realsrc ); - realpath( lpNewFileName, realdest ); + if ( realpath( lpExistingFileName, realsrc ) == nullptr ) + strncpy( realsrc, lpExistingFileName, sizeof(realsrc) - 1 ); + if ( realpath( lpNewFileName, realdest ) == nullptr ) + strncpy( realdest, lpNewFileName, sizeof(realdest) - 1 ); src = fopen( realsrc, "rb" ); if ( !src ) {