From ab78ed83b977084885265a1842e4e474e0938d9f Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 11 Jun 2020 23:24:00 +0200 Subject: [PATCH] * Fix memory leak when native compiled function is collected * src/alloc.c (cleanup_vector): Handle native compiled functions. --- src/alloc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/alloc.c b/src/alloc.c index 9a9dbb52e7b..750ffbd2dd8 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3156,6 +3156,17 @@ cleanup_vector (struct Lisp_Vector *vector) PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); dispose_comp_unit (cu, true); } + else if (NATIVE_COMP_FLAG + && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) + { + struct Lisp_Subr *subr = + PSEUDOVEC_STRUCT (vector, Lisp_Subr); + if (subr->native_comp_u[0]) + { + xfree (subr->symbol_name); + xfree (subr->native_c_name[0]); + } + } } /* Reclaim space used by unmarked vectors. */ -- 2.39.5