Skip to content

Commit 5027f71

Browse files
committed
free sig_info in pdlua_object_free
1 parent e691179 commit 5027f71

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pdlua.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -741,12 +741,6 @@ static void pdlua_free( t_pdlua *o /**< The object to destruct. */)
741741
lua_pop(__L(), 1); /* pop the global "pd" */
742742
PDLUA_DEBUG("pdlua_free: end. stack top %d", lua_gettop(__L()));
743743

744-
// Free sig_info if it exists
745-
if (o->sig_info) {
746-
freebytes(o->sig_info, o->sig_count * sizeof(t_pdlua_siginfo));
747-
o->sig_info = NULL;
748-
}
749-
750744
// Collect garbage
751745
// If we don't do this here, it could potentially leak if no other pdlua objects are used afterwards
752746
lua_gc(__L(), LUA_GCCOLLECT);
@@ -1190,10 +1184,10 @@ static void pdlua_dsp(t_pdlua *x, t_signal **sp){
11901184
freebytes(x->sig_info, x->sig_count * sizeof(t_pdlua_siginfo));
11911185
x->sig_info = NULL;
11921186
}
1193-
1187+
11941188
x->sig_info = (t_pdlua_siginfo *)getbytes(sum * sizeof(t_pdlua_siginfo));
11951189
x->sig_count = sum;
1196-
1190+
11971191
for (int i = 0; i < sum; i++) {
11981192
x->sig_info[i].vec = sp[i]->s_vec;
11991193
#if PD_MULTICHANNEL
@@ -1937,6 +1931,12 @@ static int pdlua_object_free(lua_State *L)
19371931
free(o->out);
19381932
o->out = NULL;
19391933
}
1934+
1935+
if (o->sig_info)
1936+
{
1937+
freebytes(o->sig_info, o->sig_count * sizeof(t_pdlua_siginfo));
1938+
o->sig_info = NULL;
1939+
}
19401940
}
19411941
}
19421942
PDLUA_DEBUG("pdlua_object_free: end. stack top is %d", lua_gettop(L));

0 commit comments

Comments
 (0)