Fix segmentation fault on `strftime/1` and `strflocaltime/1` (#3271)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
When we use a large format string to `strftime/1` and `strflocaltime/1`, we get segmentation fault. This happens because the result buffer is allocated on the stack using `alloca` function, and `strftime` function writes out of the space when the size is not enough to format time. I fixed the segmentation fault issue by allocating the result buffer on the heap using `malloc` function, because `alloca` function does not provide a way to detect insufficient space.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+18 added−25 removed
- other:+18 added−25 removed