From dd310a2b40b0bd435537f0517fc78d05dcd3fefd Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Tue, 25 Sep 2001 22:21:14 +0000 Subject: [PATCH] protects against crash when calling smprintf with a null argument. r=me, sr=darin@netscape. patch submitted by risto.kankkunen@iki.fi. bug number 100293. git-svn-id: svn://10.0.0.236/trunk@103738 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/ds/nsTextFormatter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mozilla/xpcom/ds/nsTextFormatter.cpp b/mozilla/xpcom/ds/nsTextFormatter.cpp index 2c88488116e..11188ccf456 100644 --- a/mozilla/xpcom/ds/nsTextFormatter.cpp +++ b/mozilla/xpcom/ds/nsTextFormatter.cpp @@ -525,11 +525,12 @@ static int cvt_s(SprintfState *ss, const char *s, int width, int prec, PRUnichar buf[256]; PRUnichar *retbuf = nsnull; - retbuf = UTF8ToUCS2(s, nsCRT::strlen(s), buf, 256); + if (s) { + retbuf = UTF8ToUCS2(s, nsCRT::strlen(s), buf, 256); - if(nsnull == retbuf) - return -1; - + if(nsnull == retbuf) + return -1; + } int ret = cvt_S(ss, retbuf, width, prec, flags); if(retbuf != buf)