From d8669a2998e9bf897a73f3e3153ca97087ee668b Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Mon, 23 May 2022 12:44:01 +0100 Subject: [PATCH] Bump cppcheck version to 2.8 --- .github/workflows/build.yml | 2 +- fontdump/fontdump.c | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eba7c1ac..9b004fd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,7 +129,7 @@ jobs: CC: gcc # This is required to use a version of cppcheck other than that # supplied with the operating system - CPPCHECK_VER: 2.7 + CPPCHECK_VER: 2.8 CPPCHECK_REPO: https://github.com/danmar/cppcheck.git steps: # This is currently the only way to get a version into diff --git a/fontdump/fontdump.c b/fontdump/fontdump.c index 03609cf0..8379e692 100644 --- a/fontdump/fontdump.c +++ b/fontdump/fontdump.c @@ -72,14 +72,18 @@ msg(char *msg1, ...) static int show_last_error(void) { - LPVOID lpMsgBuf; - - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&lpMsgBuf, 0, NULL); - msg("GetLastError - %s", lpMsgBuf); - LocalFree(lpMsgBuf); + LPVOID lpMsgBuf = NULL; + DWORD len; + len = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&lpMsgBuf, 0, NULL); + if (len > 0) + { + msg("GetLastError - %s", lpMsgBuf); + LocalFree(lpMsgBuf); + } return 0; }