Commit d6cfcc7b authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix invalid reads in iemmatrix

parent 9b981acc
......@@ -83,7 +83,7 @@ static void *newMTXBessel (t_symbol *s, int argc, t_atom *argv)
x->h_re = 0;
x->h_im = 0;
x->l=0;
fsym=atom_getsymbol(argv);
fsym= argc ? atom_getsymbol(argv) : &s_;
if (fsym->s_name!=0)
whichfunction=fsym->s_name[0];
switch (whichfunction) {
......@@ -96,7 +96,7 @@ static void *newMTXBessel (t_symbol *s, int argc, t_atom *argv)
case 'Y':
x->list_h_im_out = outlet_new (&x->x_obj, gensym("matrix"));
}
nmax=(int) atom_getfloat(argv+1);
nmax= argc > 1 ? (int) atom_getfloat(argv+1) : 0;
if (nmax<0)
nmax=0;
x->nmax=nmax;
......
......@@ -114,7 +114,7 @@ static void *newMTXEig (t_symbol *s, int argc, t_atom *argv)
x->list_l_out_re = outlet_new (&x->x_obj, gensym("list"));
x->list_l_out_im = outlet_new (&x->x_obj, gensym("list"));
if (atom_getsymbol(argv)==gensym("v")) {
if (argc && atom_getsymbol(argv)==gensym("v")) {
x->withevs=1;
x->list_q_out_re = outlet_new (&x->x_obj, gensym("matrix"));
x->list_q_out_im = outlet_new (&x->x_obj, gensym("matrix"));
......
......@@ -22,6 +22,7 @@ void *newMtxEITilde(t_symbol *s, int argc, t_atom *argv)
{
int sd=1;
int sg=1;
t_atom sane_defaults[1];
mtx_ei_tilde *x = (mtx_ei_tilde*) pd_new(mtx_ei_tilde_class);
x->sig_in_left=0;
x->sig_in_right=0;
......@@ -32,6 +33,12 @@ void *newMtxEITilde(t_symbol *s, int argc, t_atom *argv)
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
x->message_outlet=(t_outlet*)outlet_new(&x->x_obj,&s_list);
/* Prevent an invalid read */
if (!argc) {
SETFLOAT(sane_defaults, 0.);
argv = sane_defaults;
argc = 1;
}
if (argc > 2) {
sd = atom_getint(argv++);
sg = argc-1;
......
......@@ -83,7 +83,7 @@ static void *newMTXSh (t_symbol *s, int argc, t_atom *argv)
x->theta = 0;
x->ws = 0;
x->l=0;
nmax=(int) atom_getfloat(argv);
nmax= argc ? (int) atom_getfloat(argv) : 0;
if (nmax<0)
nmax=0;
x->nmax=nmax;
......
......@@ -80,7 +80,7 @@ static void *newMTXSph (t_symbol *s, int argc, t_atom *argv)
x->h_re = 0;
x->h_im = 0;
x->l=0;
fsym=atom_getsymbol(argv);
fsym= argc ? atom_getsymbol(argv) : &s_;
if (fsym->s_name!=0)
whichfunction=fsym->s_name[0];
switch (whichfunction) {
......@@ -93,7 +93,7 @@ static void *newMTXSph (t_symbol *s, int argc, t_atom *argv)
case 'y':
x->list_h_im_out = outlet_new (&x->x_obj, gensym("matrix"));
}
nmax=(int) atom_getfloat(argv+1);
nmax= argc > 1 ? (int) atom_getfloat(argv+1) : 0;
if (nmax<0)
nmax=0;
x->nmax=nmax;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment