[PD] zexy list2symbol ... corrected

Juha Vehviläinen jusukoti at atp.fi
Fri Aug 17 15:09:11 CEST 2001


Ok, I was able to trace and correct a memory bug in zexy's
list2symbol, and the corrected list2symbol_bang looks like this:

(in z_strings.c)

----- clip -----
static void list2symbol_bang(t_list2symbol *x)
{
  char *str=0, *s2;
  int n=0;

  binbuf_gettext(x->bbuf, &str, &n);

//  str[n]=0; // memory bug!
  s2 = malloc(n+1);
  strncpy(s2, str, n);
  s2[n]=0;

  outlet_symbol(x->x_obj.ob_outlet, gensym(s2/*str*/));
  freebytes(str, n);
  free(s2);
}
----- clip -----

I'm no c expert, so I'm sure you'll make a similar, proper fix
in the next zexy-patch...

It seems that binbuf_gettext() only allocs n bytes of memory for str,
and doesn't put a \0 at the end, why so?

As I said, list2symbol is essential...

jusu

----- Original Message -----
From: "Johannes M Zmoelnig" <zmoelnig at iem.kug.ac.at>
To: "Juha Vehviläinen" <jusu at iki.fi>
Cc: <pd-list at iem.kug.ac.at>
Sent: Thursday, August 16, 2001 10:16 PM
Subject: Re: zexy list2symbol .. problem


> maybe you could have alook at the code yourself - seems like a memory
> allocation problem somehow.






More information about the Pd-list mailing list