From 9908a4360a4433d02f45e4cd3f7e8bb380e77594 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 19 Jan 2021 17:10:58 +0000 Subject: [PATCH] [Minor] Rspamadm fix use after free --- lualib/rspamadm/mime.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lualib/rspamadm/mime.lua b/lualib/rspamadm/mime.lua index 6294f373f..8bd2478c8 100644 --- a/lualib/rspamadm/mime.lua +++ b/lualib/rspamadm/mime.lua @@ -266,6 +266,7 @@ end local function extract_handler(opts) local out_elts = {} + local tasks = {} local process_func if opts.words then @@ -415,11 +416,12 @@ local function extract_handler(opts) end table.insert(out_elts[fname], "") - - task:destroy() -- No automatic dtor + table.insert(tasks, task) end print_elts(out_elts, opts, process_func) + -- To avoid use after free we postpone tasks destruction + for _,task in ipairs(tasks) do task:destroy() end end local function stat_handler(opts) -- 2.39.5