cpython
cpython copied to clipboard
Add a warning message about PyOS_snprintf
The top google result for "determine sprintf buffer size" is https://stackoverflow.com/a/3923207/102441, which advocates code along the lines of
int size = snprintf(NULL, 0, "%d", 132);
char * a = malloc(size + 1);
sprintf(a, "%d", 132);
Unfortunately, this does not work for PyOS_snprintf
, as it includes an assert
to ensure the arguments are not NULL
and 0
.
This PR simply documents this limitation.