Harvey-OS / harvey

A distributed operating system
https://harvey-os.org/
MIT License
1.44k stars 105 forks source link

devtls: fix bwrite memory leak when channel stops being open #1181

Closed dancrossnyc closed 2 years ago

dancrossnyc commented 2 years ago

tlsbwrite() would call checkstate() before calling tlsrecwrite() to make sure the channel is open. however, because checkstate() only raises the error, the Block* passed wont be freed and would result in a memory leak.

move the checkstate() call inside tlsrecwrite() to reuse the error handling that frees the block on error.

[Authored by Cinap for 9front; DCO ok for Harvey by cross@: 9front uses the MIT license for all changes unless otherwise noted: http://fqa.9front.org/fqa0.html#0.2.4.4]

Signed-off-by: Dan Cross cross@gajendra.net