Cosmopolitan's printf-family functions currently crash if one tries to
format a floating point number with a large precision (large enough
that gdtoa tries to allocate memory to format the number) when under
memory pressure (i.e. when malloc fails), because gdtoa fails to check
if malloc fails.
The added tests (which would previously crash under cosmopolitan
without this patch) show how to reproduce the issue.
This patch fixes this, and adds the aforementioned tests.
Cosmopolitan's printf-family functions currently crash if one tries to format a floating point number with a large precision (large enough that gdtoa tries to allocate memory to format the number) when under memory pressure (i.e. when malloc fails), because gdtoa fails to check if malloc fails.
The added tests (which would previously crash under cosmopolitan without this patch) show how to reproduce the issue.
This patch fixes this, and adds the aforementioned tests.