diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-05-26 22:07:28 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-05-26 22:07:28 (GMT) |
commit | 933d3731deab19b2565fbb0d07511e67277d3d58 (patch) | |
tree | e532e7cc01734749d17751f5e9b96ea85a8bd274 /Python | |
parent | c1c83bb0dec06ecc4580935a8f77782d3beaff4d (diff) | |
download | cpython-933d3731deab19b2565fbb0d07511e67277d3d58.zip cpython-933d3731deab19b2565fbb0d07511e67277d3d58.tar.gz cpython-933d3731deab19b2565fbb0d07511e67277d3d58.tar.bz2 |
Fix issue2588: Do not execute str[size-1] = '\0' when a 0 size is
passed in. (The assert won't prevent this in non-debug builds).
Diffstat (limited to 'Python')
-rw-r--r-- | Python/mysnprintf.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/mysnprintf.c b/Python/mysnprintf.c index 8c47794..3173863 100644 --- a/Python/mysnprintf.c +++ b/Python/mysnprintf.c @@ -98,7 +98,8 @@ PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) PyMem_FREE(buffer); #endif Done: - str[size-1] = '\0'; + if (size > 0) + str[size-1] = '\0'; return len; #undef _PyOS_vsnprintf_EXTRA_SPACE } |