From: Gregory P. Smith Date: Mon, 26 May 2008 22:07:28 +0000 (+0000) Subject: Fix issue2588: Do not execute str[size-1] = '\0' when a 0 size is X-Git-Tag: v2.6b1~224 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=933d3731deab19b2565fbb0d07511e67277d3d58;p=python 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). --- diff --git a/Python/mysnprintf.c b/Python/mysnprintf.c index 8c47794642..3173863c46 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 }