From 81157b5d4f523e709ff365c742cff90442059deb Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Thu, 8 Jul 2021 11:22:33 +0800 Subject: [PATCH] fix memory leak when reproc_start() fails --- src/api/process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/process.c b/src/api/process.c index 8460740f..6442d0d2 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -140,7 +140,10 @@ static int process_start(lua_State* L) } ); - ASSERT_REPROC_ERRNO(L, out); + if (out < 0) { + reproc_destroy(proc); + L_RETURN_REPROC_ERROR(L, out); + } process_t* self = lua_newuserdata(L, sizeof(process_t)); self->process = proc;