Skip to content

Commit

Permalink
free sig_info in pdlua_object_free
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-wes committed Oct 18, 2024
1 parent e691179 commit 5027f71
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pdlua.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,12 +741,6 @@ static void pdlua_free( t_pdlua *o /**< The object to destruct. */)
lua_pop(__L(), 1); /* pop the global "pd" */
PDLUA_DEBUG("pdlua_free: end. stack top %d", lua_gettop(__L()));

// Free sig_info if it exists
if (o->sig_info) {
freebytes(o->sig_info, o->sig_count * sizeof(t_pdlua_siginfo));
o->sig_info = NULL;
}

// Collect garbage
// If we don't do this here, it could potentially leak if no other pdlua objects are used afterwards
lua_gc(__L(), LUA_GCCOLLECT);
Expand Down Expand Up @@ -1190,10 +1184,10 @@ static void pdlua_dsp(t_pdlua *x, t_signal **sp){
freebytes(x->sig_info, x->sig_count * sizeof(t_pdlua_siginfo));
x->sig_info = NULL;
}

x->sig_info = (t_pdlua_siginfo *)getbytes(sum * sizeof(t_pdlua_siginfo));
x->sig_count = sum;

for (int i = 0; i < sum; i++) {
x->sig_info[i].vec = sp[i]->s_vec;
#if PD_MULTICHANNEL
Expand Down Expand Up @@ -1937,6 +1931,12 @@ static int pdlua_object_free(lua_State *L)
free(o->out);
o->out = NULL;
}

if (o->sig_info)
{
freebytes(o->sig_info, o->sig_count * sizeof(t_pdlua_siginfo));
o->sig_info = NULL;
}
}
}
PDLUA_DEBUG("pdlua_object_free: end. stack top is %d", lua_gettop(L));
Expand Down

0 comments on commit 5027f71

Please sign in to comment.