sansapatcher: Correct use of FormatMessageA() for windows builds

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Sat, 4 Jul 2026 13:05:01 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit b54b10dc6db2af78bb6aebfc1bfe541f98e68b70
Author: Solomon Peachy <[email protected]>
Date:   Sat Jul 4 13:04:05 2026 -0400

    sansapatcher:  Correct use of FormatMessageA() for windows builds
    
    Change-Id: I3e026400fa0440221b4fd6d8c96f515737e36433

diff --git a/utils/sansapatcher/sansaio-win32.c b/utils/sansapatcher/sansaio-win32.c
index 867c7c183d..6280e40911 100644
--- a/utils/sansapatcher/sansaio-win32.c
+++ b/utils/sansapatcher/sansaio-win32.c
@@ -60,12 +60,13 @@ void sansa_print_error(char* msg)
     LPSTR pMsgBuf = NULL;
 
     printf(msg);
-    FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+    if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
                   FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
-                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), pMsgBuf,
-                  0, NULL);
-    printf(pMsgBuf);
-    LocalFree(pMsgBuf);
+                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&pMsgBuf,
+                       0, NULL)) {
+        printf(pMsgBuf);
+        LocalFree(pMsgBuf);
+    }
 }
 
 int sansa_open(struct sansa_t* sansa, int silent)
@@ -214,4 +215,3 @@ int sansa_write(struct sansa_t* sansa, int nbytes)
     return count;
 }
 #endif
-
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs