winecfg: Prevent crash when clearing volume serial number input.

This commit is contained in:
Jörg Höhle 2008-12-16 10:29:35 +01:00 committed by Alexandre Julliard
parent 061302483f
commit cda8e4410a
2 changed files with 6 additions and 4 deletions

View File

@ -187,7 +187,7 @@ static void set_drive_serial( char letter, DWORD serial )
HANDLE hFile;
filename[0] = letter;
WINE_TRACE("Putting serial number of %08x into file '%s'\n", serial, filename);
WINE_TRACE("Putting serial number of %08X into file '%s'\n", serial, filename);
hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)

View File

@ -520,10 +520,11 @@ static void on_edit_changed(HWND dialog, WORD id)
char *serial;
serial = get_text(dialog, id);
current_drive->serial = strtoul( serial, NULL, 16 );
current_drive->serial = serial ? strtoul( serial, NULL, 16 ) : 0;
HeapFree(GetProcessHeap(), 0, serial);
current_drive->modified = TRUE;
WINE_TRACE("set serial to %08x\n", current_drive->serial);
WINE_TRACE("set serial to %08X\n", current_drive->serial);
/* enable the apply button */
SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
@ -775,7 +776,8 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
current_drive->label = str;
str = get_textW(dialog, IDC_EDIT_SERIAL);
current_drive->serial = strtoulW( str, NULL, 16 );
current_drive->serial = str ? strtoulW( str, NULL, 16 ) : 0;
HeapFree(GetProcessHeap(), 0, str);
current_drive->modified = TRUE;
/* TODO: we don't have a device at this point */