[PATCH] winevdm: Abstract references to /dosbox

Gerald Pfeifer gerald at pfeifer.com
Fri Oct 2 08:52:41 CDT 2020


A user has shared the want to go with dosbox-staging instead of
classic DOSBox. To make that easier, and our current code easier
to maintain, abstract references to /dosbox.

On the way use strlen() instead of sizeof(). That is already used
earlier in that function, it is more robust, and still computed at
compile time if feasible.

Gerald


Signed-off-by: Gerald Pfeifer <gerald at pfeifer.com>
---
 programs/winevdm/winevdm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/programs/winevdm/winevdm.c b/programs/winevdm/winevdm.c
index bfc47b8853..43019fbd63 100644
--- a/programs/winevdm/winevdm.c
+++ b/programs/winevdm/winevdm.c
@@ -35,6 +35,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(winevdm);
 
+const char DOSBOX[] = "/dosbox";
 
 /*** PIF file structures ***/
 #include "pshpack1.h"
@@ -118,7 +119,7 @@ static char *find_dosbox(void)
 
     envpath_len = strlen( envpath );
     path = HeapAlloc( GetProcessHeap(), 0, envpath_len + 1 );
-    buffer = HeapAlloc( GetProcessHeap(), 0, envpath_len + sizeof("/dosbox") );
+    buffer = HeapAlloc( GetProcessHeap(), 0, envpath_len + strlen(DOSBOX) + 1 );
     strcpy( path, envpath );
 
     p = path;
@@ -130,7 +131,7 @@ static char *find_dosbox(void)
         while (*p && *p != ':') p++;
         if (*p == ':') *p++ = 0;
         strcpy( buffer, dir );
-        strcat( buffer, "/dosbox" );
+        strcat( buffer, DOSBOX );
         if (!stat( buffer, &st ))
         {
             HeapFree( GetProcessHeap(), 0, path );
-- 
2.27.0



More information about the wine-devel mailing list