From: Nicholas Clark <nick@ccl4.org>
Date: Sat, 29 Apr 2006 23:35:52 +0000 (+0000)
Subject: Coverity disliked us passing a negative length to vsnprintf().
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6a841143011641ad36ad4f8e2f2896eb0e1a59dc;p=p5sagit%2Fp5-mst-13.2.git

Coverity disliked us passing a negative length to vsnprintf().

p4raw-id: //depot/perl@28020
---

diff --git a/perlio.c b/perlio.c
index 8d8a4ec..24f419f 100644
--- a/perlio.c
+++ b/perlio.c
@@ -5143,7 +5143,7 @@ PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap)
 {
     dVAR;
 #ifdef USE_VSNPRINTF
-    const int val = vsnprintf(s, n, fmt, ap);
+    const int val = vsnprintf(s, n > 0 ? n : 0, fmt, ap);
 #else
     const int val = vsprintf(s, fmt, ap);
 #endif /* #ifdef USE_VSNPRINTF */