From 17045056143d33fd05f53e97d323f9fefd584429 Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Wed, 9 Feb 2022 21:36:14 -0800 Subject: [PATCH] Deallocate the closure if thread spawning failed --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e7a8a77..768ff76 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,6 +58,8 @@ pub unsafe extern "C" fn pthread_create( if handle.is_null() { // There was some error, but libctru doesn't expose the result. // We assume there was an incorrect parameter (such as too low of a priority). + // We also need to clean up the closure at this time. + drop(Box::from_raw(main)); return libc::EINVAL; }