Skip to content

Commit b36e1e0

Browse files
benlorenzbarche
authored andcommitted
get_module_functions: gc protect CppFunctionInfo struct during push_back
1 parent 46cb3b2 commit b36e1e0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/c_interface.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ JLCXX_API jl_array_t* get_module_functions(jl_module_t* jlmod)
147147
{
148148
Array<jl_value_t*> arg_default_values_array;
149149
jl_value_t* boxed_n_kwargs = nullptr;
150-
JL_GC_PUSH2(arg_default_values_array.gc_pointer(), &boxed_n_kwargs);
150+
jl_value_t* cppfuncinfo = nullptr;
151+
JL_GC_PUSH3(arg_default_values_array.gc_pointer(), &boxed_n_kwargs, &cppfuncinfo);
151152

152153
fill_types_vec(arg_types_array, f.argument_types());
153154

@@ -169,7 +170,7 @@ JLCXX_API jl_array_t* get_module_functions(jl_module_t* jlmod)
169170
julia_return_type = ccall_return_type;
170171
}
171172

172-
function_array.push_back(jl_new_struct(g_cppfunctioninfo_type,
173+
cppfuncinfo = jl_new_struct(g_cppfunctioninfo_type,
173174
f.name(),
174175
arg_types_array.wrapped(),
175176
ccall_return_type,
@@ -181,7 +182,8 @@ JLCXX_API jl_array_t* get_module_functions(jl_module_t* jlmod)
181182
arg_names_array.wrapped(),
182183
arg_default_values_array.wrapped(),
183184
boxed_n_kwargs
184-
));
185+
);
186+
function_array.push_back(cppfuncinfo);
185187
JL_GC_POP();
186188
}
187189
JL_GC_POP();

0 commit comments

Comments
 (0)