[misc] fix some benign Coverity warnings

This commit is contained in:
Pete Batard 2023-06-18 19:09:15 +02:00
parent be5b590cfb
commit 7eb9a6f16b
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
4 changed files with 17 additions and 22 deletions

View File

@ -1274,7 +1274,6 @@ out:
to_windows_path(symlinked_syslinux); to_windows_path(symlinked_syslinux);
uprintf("Created: %s\\%s → %s", symlinked_syslinux, efi_cfg_name[i], &path[2]); uprintf("Created: %s\\%s → %s", symlinked_syslinux, efi_cfg_name[i], &path[2]);
to_unix_path(symlinked_syslinux); to_unix_path(symlinked_syslinux);
fd = NULL;
} }
} }
} else if (HAS_BOOTMGR(img_report) && enable_ntfs_compression) { } else if (HAS_BOOTMGR(img_report) && enable_ntfs_compression) {

View File

@ -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) static __inline int GetWindowTextU(HWND hWnd, char* lpString, int nMaxCount)
{ {
int ret = 0; int ret = 0;
DWORD err = ERROR_INVALID_DATA; DWORD err = ERROR_INVALID_PARAMETER;
if (nMaxCount < 0) if (lpString == NULL || nMaxCount < 1)
return 0; goto out;
// Handle the empty string as GetWindowTextW() returns 0 then // Handle the empty string as GetWindowTextW() returns 0 then
if ((lpString != NULL) && (nMaxCount > 0)) lpString[0] = 0;
lpString[0] = 0;
// coverity[returned_null]
walloc(lpString, nMaxCount); walloc(lpString, nMaxCount);
ret = GetWindowTextW(hWnd, wlpString, nMaxCount); ret = GetWindowTextW(hWnd, wlpString, nMaxCount);
err = GetLastError(); 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(); err = GetLastError();
}
wfree(lpString); wfree(lpString);
if (lpString != NULL) lpString[nMaxCount - 1] = 0;
lpString[nMaxCount - 1] = 0; out:
SetLastError(err); SetLastError(err);
return ret; return ret;
} }

View File

@ -800,10 +800,8 @@ out:
fclose(fd_in); fclose(fd_in);
fd_in = NULL; fd_in = NULL;
} }
if (fd_out != NULL) { if (fd_out != NULL)
fclose(fd_out); fclose(fd_out);
fd_out = NULL;
}
// If an insertion occurred, delete existing file and use the new one // If an insertion occurred, delete existing file and use the new one
if (ret != NULL) { if (ret != NULL) {
@ -821,8 +819,10 @@ out:
} else { } else {
uprintf("Could not write '%s' - original file has been left unmodified\n", filename); uprintf("Could not write '%s' - original file has been left unmodified\n", filename);
ret = NULL; ret = NULL;
if (fd_in != NULL) fclose(fd_in); if (fd_in != NULL)
if (fd_out != NULL) fclose(fd_out); fclose(fd_in);
if (fd_out != NULL)
fclose(fd_out);
} }
} }
if (wtmpname != NULL) if (wtmpname != NULL)

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.2.2051" CAPTION "Rufus 4.2.2052"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,2,2051,0 FILEVERSION 4,2,2052,0
PRODUCTVERSION 4,2,2051,0 PRODUCTVERSION 4,2,2052,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.2.2051" VALUE "FileVersion", "4.2.2052"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.2.exe" VALUE "OriginalFilename", "rufus-4.2.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.2.2051" VALUE "ProductVersion", "4.2.2052"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"