Carp icon indicating copy to clipboard operation
Carp copied to clipboard

`format` leaks memory

Open iacore opened this issue 3 years ago • 1 comments

> (format "%d%d" 1)
1-1900850528
> (format "%d %d" 1)
1 279724704

iacore avatar Sep 19 '22 13:09 iacore

Thanks for reporting!

For a safe multi-argument version, please use fmt. format is a thin wrapper around the C APIs for single arguments and doesn’t do any checking. fmt is vararg, and does compile-time checking to see that the number of formatting primitives and arguments checks out.

We could and should probably still add a (compile-time) check that ensures that there is only one formatting expression in the first argument to format.

hellerve avatar Sep 19 '22 14:09 hellerve