Skip to content

Commit c81932e

Browse files
authored
Merge pull request #176 from bgamari/T17926
Windows: Fix buffer size of QueryInformationJobObject request
2 parents 229674d + 1afc36e commit c81932e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cbits/runProcess.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,10 @@ waitForJobCompletion ( HANDLE hJob )
862862
JOBOBJECT_BASIC_PROCESS_ID_LIST *pid_list = NULL;
863863

864864
while (true) {
865+
size_t pid_list_size = sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * (process_count - 1);
866+
865867
if (pid_list == NULL) {
866-
pid_list = malloc(sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * process_count);
868+
pid_list = malloc(pid_list_size);
867869
pid_list->NumberOfAssignedProcesses = process_count;
868870
}
869871

@@ -872,7 +874,7 @@ waitForJobCompletion ( HANDLE hJob )
872874
hJob,
873875
JobObjectBasicProcessIdList,
874876
pid_list,
875-
sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST),
877+
pid_list_size,
876878
NULL);
877879

878880
if (!success && GetLastError() == ERROR_MORE_DATA) {

0 commit comments

Comments
 (0)