From 7eb9a6f16bd4fa9689750be6366450fca7d70943 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 18 Jun 2023 19:09:15 +0200 Subject: [PATCH] [misc] fix some benign Coverity warnings --- src/iso.c | 1 - src/msapi_utf8.h | 18 +++++++----------- src/parser.c | 10 +++++----- src/rufus.rc | 10 +++++----- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/iso.c b/src/iso.c index 0cb4ee50..b74dad4d 100644 --- a/src/iso.c +++ b/src/iso.c @@ -1274,7 +1274,6 @@ out: to_windows_path(symlinked_syslinux); uprintf("Created: %s\\%s → %s", symlinked_syslinux, efi_cfg_name[i], &path[2]); to_unix_path(symlinked_syslinux); - fd = NULL; } } } else if (HAS_BOOTMGR(img_report) && enable_ntfs_compression) { diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index 6ff77437..3762ea4e 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -344,23 +344,19 @@ static __inline int DrawTextU(HDC hDC, LPCSTR lpText, int nCount, LPRECT lpRect, static __inline int GetWindowTextU(HWND hWnd, char* lpString, int nMaxCount) { int ret = 0; - DWORD err = ERROR_INVALID_DATA; - if (nMaxCount < 0) - return 0; + DWORD err = ERROR_INVALID_PARAMETER; + if (lpString == NULL || nMaxCount < 1) + goto out; // Handle the empty string as GetWindowTextW() returns 0 then - if ((lpString != NULL) && (nMaxCount > 0)) - lpString[0] = 0; - // coverity[returned_null] + lpString[0] = 0; walloc(lpString, nMaxCount); ret = GetWindowTextW(hWnd, wlpString, nMaxCount); err = GetLastError(); - // coverity[var_deref_model] - if ( (ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpString, lpString, nMaxCount)) == 0) ) { + if ((ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpString, lpString, nMaxCount)) == 0)) err = GetLastError(); - } wfree(lpString); - if (lpString != NULL) - lpString[nMaxCount - 1] = 0; + lpString[nMaxCount - 1] = 0; +out: SetLastError(err); return ret; } diff --git a/src/parser.c b/src/parser.c index fb312102..8cd1ccb1 100644 --- a/src/parser.c +++ b/src/parser.c @@ -800,10 +800,8 @@ out: fclose(fd_in); fd_in = NULL; } - if (fd_out != NULL) { + if (fd_out != NULL) fclose(fd_out); - fd_out = NULL; - } // If an insertion occurred, delete existing file and use the new one if (ret != NULL) { @@ -821,8 +819,10 @@ out: } else { uprintf("Could not write '%s' - original file has been left unmodified\n", filename); ret = NULL; - if (fd_in != NULL) fclose(fd_in); - if (fd_out != NULL) fclose(fd_out); + if (fd_in != NULL) + fclose(fd_in); + if (fd_out != NULL) + fclose(fd_out); } } if (wtmpname != NULL) diff --git a/src/rufus.rc b/src/rufus.rc index 636450de..6502ea7b 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 4.2.2051" +CAPTION "Rufus 4.2.2052" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,2,2051,0 - PRODUCTVERSION 4,2,2051,0 + FILEVERSION 4,2,2052,0 + PRODUCTVERSION 4,2,2052,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.2.2051" + VALUE "FileVersion", "4.2.2052" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.2.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.2.2051" + VALUE "ProductVersion", "4.2.2052" END END BLOCK "VarFileInfo"