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