Skip to content

Commit

Permalink
nsysnet: Avoid crash on NULL timeout in select (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
deReeperJosh authored Sep 2, 2024
1 parent 9a53b19 commit b069906
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Cafe/OS/libs/nsysnet/nsysnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,14 @@ void nsysnetExport_select(PPCInterpreter_t* hCPU)

timeval tv = { 0 };

if (timeOut == NULL)
{
// return immediately
cemuLog_log(LogType::Socket, "select returned immediately because of null timeout");
osLib_returnFromFunction(hCPU, 0);
return;
}

uint64 msTimeout = (_swapEndianU32(timeOut->tv_usec) / 1000) + (_swapEndianU32(timeOut->tv_sec) * 1000);
uint32 startTime = GetTickCount();
while (true)
Expand Down

0 comments on commit b069906

Please sign in to comment.