lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Fri, Jul 22, 2022 at 2:30 AM Francisco Olarte <folarte@peoplecall.com> wrote:
Not the OP, but I think what he is trying to point is simple tricks
for avoiding reallocs may be dangerous. I.e., if you make one pass,
allocate, make a second pass copying, you may encounter yourself in a
buffer overrun situation, so table.concat must be coded in a way which
tolerates degenerated table behaviour w/o crashing. Easy-peasy to do,
but worth remembering.

That's it exactly, and if you try to avoid this issue by caching the values you use to calculate the string size you could end up with even worse behavior. There's no silver bullet here that solves the problem for all possible use cases.

--