Skip to content
Snippets Groups Projects
Unverified Commit 90f2c799 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub
Browse files

Add a warning message about PyOS_snprintf (GH-95993)


(cherry picked from commit c7b22049)

Co-authored-by: default avatarEric Wieser <wieser.eric@gmail.com>
parent a3a3701f
Branches
Tags
No related merge requests found
...@@ -28,7 +28,8 @@ not. ...@@ -28,7 +28,8 @@ not.
The wrappers ensure that ``str[size-1]`` is always ``'\0'`` upon return. They The wrappers ensure that ``str[size-1]`` is always ``'\0'`` upon return. They
never write more than *size* bytes (including the trailing ``'\0'``) into str. never write more than *size* bytes (including the trailing ``'\0'``) into str.
Both functions require that ``str != NULL``, ``size > 0``, ``format != NULL`` Both functions require that ``str != NULL``, ``size > 0``, ``format != NULL``
and ``size < INT_MAX``. and ``size < INT_MAX``. Note that this means there is no equivalent to the C99
``n = snprintf(NULL, 0, ...)`` which would determine the necessary buffer size.
The return value (*rv*) for these functions should be interpreted as follows: The return value (*rv*) for these functions should be interpreted as follows:
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
would have been written had the buffer not been too small, and to set would have been written had the buffer not been too small, and to set
the last byte of the buffer to \0. At least MS _vsnprintf returns a the last byte of the buffer to \0. At least MS _vsnprintf returns a
negative value instead, and fills the entire buffer with non-\0 data. negative value instead, and fills the entire buffer with non-\0 data.
Unlike C99, our wrappers do not support passing a null buffer.
The wrappers ensure that str[size-1] is always \0 upon return. The wrappers ensure that str[size-1] is always \0 upon return.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment