mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-31 06:48:26 -04:00
[core] fix 'Bad label' errors with empty labels
* Only happens on Win7 due to MinGW not automatically initializing variables to zero on that platform. * Root of the problem was that GetWindowTextU() did not properly handle empty text controls, due to GetWindowTextW() returning 0 on empty strings. As a result, the UTF-8 label was not properly set to the empty string, but kept whatever data it contained, which is garbage on Windows 7 and resulted in an invalid label (even after sanitizing, since we don't sanitize low-level ASCII characters). * Closes #1352
This commit is contained in:
parent
c8fda3e4e8
commit
307e2f7075
2 changed files with 8 additions and 5 deletions
|
@ -329,6 +329,9 @@ static __inline int GetWindowTextU(HWND hWnd, char* lpString, int nMaxCount)
|
|||
{
|
||||
int ret = 0;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
// Handle the empty string as GetWindowTextW() returns 0 then
|
||||
if ((lpString != NULL) && (nMaxCount > 0))
|
||||
lpString[0] = 0;
|
||||
// coverity[returned_null]
|
||||
walloc(lpString, nMaxCount);
|
||||
ret = GetWindowTextW(hWnd, wlpString, nMaxCount);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue