mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-31 06:48:26 -04:00
[misc] fix some benign Coverity warnings
This commit is contained in:
parent
be5b590cfb
commit
7eb9a6f16b
4 changed files with 17 additions and 22 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue