mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-01 15:30:29 +00:00
Fix rare corner case in ntspawn.c
There could be cases when libc/proc/describefds.c calls calloc(handlecount, ..) with handlecount = 0 to initialize what will later become opt_lpExplicitHandleList. but calloc(0, ..) does not always return null so if the chosen conditional is a->opt_lpExplicitHandleList then UpdateProcThreadAttribute produces a Windows error. The modification avoids this problem.
This commit is contained in:
parent
4754f200ee
commit
823a89d3ab
1 changed files with 1 additions and 1 deletions
|
@ -166,7 +166,7 @@ static textwindows int ntspawn2(struct NtSpawnArgs *a, struct SpawnBlock *sb) {
|
|||
alist, 0, kNtProcThreadAttributeParentProcess, &a->opt_hParentProcess,
|
||||
sizeof(a->opt_hParentProcess), 0, 0);
|
||||
}
|
||||
if (ok && a->opt_lpExplicitHandleList) {
|
||||
if (ok && a->dwExplicitHandleCount) {
|
||||
ok = UpdateProcThreadAttribute(
|
||||
alist, 0, kNtProcThreadAttributeHandleList, a->opt_lpExplicitHandleList,
|
||||
a->dwExplicitHandleCount * sizeof(*a->opt_lpExplicitHandleList), 0, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue