From a7ffb3583b2f805521372e511bafdce65318903c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 24 Jun 2017 20:28:37 -0700 Subject: ffi: fix memory leak regression. The recent commit "ffi: elide useless by-value in calls." neglects to mark a few types with the by_value_in flag. The string types need it because their in action performs memory freeing, which must be done regardless of the by-value or by-pointer semantics. * ffi.c (ffi_init_types): set by_value_in to 1 for str, bstr and wstr. In general, if the type needs a release function, it needs by_value_in to be set. --- ffi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ffi.c b/ffi.c index d50854af..def21a38 100644 --- a/ffi.c +++ b/ffi.c @@ -3741,6 +3741,7 @@ static void ffi_init_types(void) struct txr_ffi_type *tft = ffi_type_struct(type); tft->in = ffi_str_in; tft->release = ffi_simple_release; + tft->by_value_in = 1; ffi_typedef(str_s, type); } @@ -3752,6 +3753,7 @@ static void ffi_init_types(void) struct txr_ffi_type *tft = ffi_type_struct(type); tft->in = ffi_bstr_in; tft->release = ffi_simple_release; + tft->by_value_in = 1; ffi_typedef(bstr_s, type); } @@ -3769,6 +3771,7 @@ static void ffi_init_types(void) struct txr_ffi_type *tft = ffi_type_struct(type); tft->in = ffi_wstr_in; tft->release = ffi_simple_release; + tft->by_value_in = 1; ffi_typedef(wstr_s, type); } -- cgit v1.2.3