Closed jessie-murray closed 2 years ago
Thanks for the quick PR!
Looking at the other call to ws_client_free
(from worker_can_read
), shouldn't it also be changed to ws_close_if_able
?
Also, this feels like the sort of bug that could easily be covered by a new test in ws-tests.py
. It seems like it's also important to check for leaks for any change dealing with memory allocation.
And lastly the CodeQL results show 4 new warnings. Although these seem unrelated to this particular change, they are worth investigating.
Looks good!
The new test does reproduce the issue reliably, and the fix solves it. I also confirmed that this is no longer reproducible with a browser. Valgrind reports no leaks.
Thanks again!
Fixes #209. A WS client socket closure could cause Webdis to schedule the send of a closing frame, leading to both
EV_READ
andEV_WRITE
scheduled events. They would both fail and each lead to a call tows_client_free
, causing a double-free and a crash.