Skip to content

Commit

Permalink
Fix null-pointer dereference on failing SDL_SYS_CreateProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Sep 30, 2024
1 parent e9bfa5b commit f605543
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/process/windows/SDL_windowsprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
return false;
}
process->internal = data;
data->process_information.hProcess = INVALID_HANDLE_VALUE;
data->process_information.hThread = INVALID_HANDLE_VALUE;

creation_flags = CREATE_UNICODE_ENVIRONMENT;

Expand Down Expand Up @@ -533,8 +535,14 @@ void SDL_SYS_DestroyProcess(SDL_Process *process)
if (io) {
SDL_CloseIO(io);
}
CloseHandle(data->process_information.hThread);
CloseHandle(data->process_information.hProcess);
if (data) {
if (data->process_information.hThread != INVALID_HANDLE_VALUE) {
CloseHandle(data->process_information.hThread);
}
if (data->process_information.hProcess != INVALID_HANDLE_VALUE) {
CloseHandle(data->process_information.hProcess);
}
}
SDL_free(data);
}

Expand Down

0 comments on commit f605543

Please sign in to comment.