summaryrefslogtreecommitdiff
path: root/core/src/fxcrt/fx_basic_bstring.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-03-11 14:25:05 -0700
committerTom Sepez <tsepez@chromium.org>2015-03-11 14:25:05 -0700
commit2080b3e1b18126628890c61a62eca28dcd65818e (patch)
treefb4fee30fb2bbbc91d7543fec4455e4379fcc32a /core/src/fxcrt/fx_basic_bstring.cpp
parent404e7e76fa8007468bd0ef58305ccff1895dfbf7 (diff)
downloadpdfium-2080b3e1b18126628890c61a62eca28dcd65818e.tar.xz
Merge to XFA: Kill remaining sprintfs
There is fx_codec_png.cpp that has a sprintf under XFA that was not present in master. Original Review URL: https://codereview.chromium.org/999543002 R=thestig@chromium.org Review URL: https://codereview.chromium.org/995993002
Diffstat (limited to 'core/src/fxcrt/fx_basic_bstring.cpp')
-rw-r--r--core/src/fxcrt/fx_basic_bstring.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 5c8a2fa8f3..895c8e560e 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -676,10 +676,10 @@ void CFX_ByteString::FormatV(FX_LPCSTR lpszFormat, va_list argList)
if (nWidth + nPrecision > 100) {
nItemLen = nPrecision + nWidth + 128;
} else {
- double f;
char pszTemp[256];
- f = va_arg(argList, double);
- FXSYS_sprintf(pszTemp, "%*.*f", nWidth, nPrecision + 6, f );
+ double f = va_arg(argList, double);
+ memset(pszTemp, 0, sizeof(pszTemp));
+ FXSYS_snprintf(pszTemp, sizeof(pszTemp) - 1, "%*.*f", nWidth, nPrecision + 6, f);
nItemLen = (FX_STRSIZE)FXSYS_strlen(pszTemp);
}
break;
@@ -697,9 +697,11 @@ void CFX_ByteString::FormatV(FX_LPCSTR lpszFormat, va_list argList)
}
nMaxLen += nItemLen;
}
+ nMaxLen += 32; // Fudge factor.
GetBuffer(nMaxLen);
if (m_pData) {
- FXSYS_vsprintf(m_pData->m_String, lpszFormat, argListSave);
+ memset(m_pData->m_String, 0, nMaxLen);
+ FXSYS_vsnprintf(m_pData->m_String, nMaxLen - 1, lpszFormat, argListSave);
ReleaseBuffer();
}
va_end(argListSave);