-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed coverity in acl_hostch.cpp #233
Conversation
…RSE_INULL) Function was accessing pipe->host_pipe_info->m_lock before checking that pipe->host_pipe_info is NULL. If pipe->host_pipe_info is NULL, then it cannot be dereferenced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @haoxian2! The change looks good, but the underlying issue leading to these mistakes is that the mutex is manually locked and unlocked. Would it be feasible to change host_pipe_t::m_lock
from acl_mutex_t
to std::mutex
and use the RAII-safe std::scoped_lock
to carry out the locking? (Admittedly one still has to get the locking after NULL check right since C++ does not provide a primitive to enforce locking, but cognitive overload is reduced significantly.)
@pcolberg I think it's feasible, a quick search indicates that
Since it's mostly used in |
Thanks @haoxian2 for looking into this. The replacement should be straight-forward, but since the number of occurrences you found is nontrivial it is better suited for separate PR. An issue you may or may not run into is that the |
@zibaiwan @haoxian2 Keeping this PR unmerged for now since @sophimao is preparing a revision of #214 to address a performance regression on Windows, which can go into |
@pcolberg , I think it's safe to merge this PR now, just want to double confirm with you. |
Fixed coverity in acl_hostch.cpp: Dereference before null check (REVERSE_INULL)
Function was accessing
pipe->host_pipe_info->m_lock
before checking thatpipe->host_pipe_info
isNULL
. Ifpipe->host_pipe_info
isNULL
, then it cannot be dereferenced.