[PD-dev] how to dinamically allocate t_atom & t_float size?

Jonathan Wilkes jancsika at yahoo.com
Fri Dec 4 07:30:20 CET 2020


> You can avoid the free() if you HAVE_ALLOCA with
>        t_atom* at = (t_atom*)alloca(ac * sizeof(t_atom));
If the user can control ac, then you have likely introduced a potential crasher just to avoid a call to free.
Systemd had a cve from using alloca awhile back. Pd recently fixed a crasher due to alloca. In neither case was alloca necessary.
I'd strongly advise to avoid it in general.

In fact, the next time I get on a Windows machine I bet I can create a trivial Pd patch to blow the stack using only `[list prepend]` and `[list fromsymbol]`. If so it will be 100% due to alloca, and an ostensibly defensive use of it at that. (Have a look at the code for the ATOMS_ALLOCA macro if someone wants to beat me to it.)

Best,
Jonathan
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20201204/89d5d557/attachment-0001.html>


More information about the Pd-dev mailing list