When borting bthread creation early, we would end up calling bthread_free on a NULL bthread, causing a NULL pointer dereference. As it's customary for free functions to gracefully handle a NULL argument, have bthread_free follow suit. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- common/bthread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/bthread.c b/common/bthread.c index 46e6987149bb..d40c0b0f9e3a 100644 --- a/common/bthread.c +++ b/common/bthread.c @@ -70,6 +70,8 @@ bool bthread_is_main(struct bthread *bthread) static void bthread_free(struct bthread *bthread) { + if (!bthread) + return; free(bthread->stack); free(bthread->name); free(bthread); -- 2.30.2