summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Python/mysnprintf.c3
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
}