diff Python/mysnprintf.c @ 47345:e1a4bf91b2ae legacy-trunk

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).
author Gregory P. Smith <greg@mad-scientist.com>
date Mon, 26 May 2008 22:07:28 +0000
parents a8cc8e6f0c1a
children fd25030223b0
line wrap: on
line diff
--- a/Python/mysnprintf.c	Mon May 26 21:44:26 2008 +0000
+++ b/Python/mysnprintf.c	Mon May 26 22:07:28 2008 +0000
@@ -98,7 +98,8 @@
 	PyMem_FREE(buffer);
 #endif
 Done:
-	str[size-1] = '\0';
+	if (size > 0)
+		str[size-1] = '\0';
 	return len;
 #undef _PyOS_vsnprintf_EXTRA_SPACE
 }