!167 增加判断获取watcher时fd有效性验证

Merge pull request !167 from liaoxingxing/libuvWatchersValid
This commit is contained in:
openharmony_ci 2024-08-22 14:58:24 +00:00 committed by Gitee
commit 0b9f18147e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1510,8 +1510,13 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
continue;
}
#ifndef USE_OHOS_DFX
assert(fd >= 0);
assert((unsigned) fd < loop->nwatchers);
#else
if (fd < 0 || (unsigned) fd >= loop->nwatchers)
continue;
#endif
w = loop->watchers[fd];