diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-09-12 14:49:29 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-13 00:09:28 +0000 |
commit | f2ca50ffa2d26a6c023add24e92adbe6b28bfcc9 (patch) | |
tree | 400be20cc2289c35d8bf61ba66ab56bdba14fa8b /core/fxcrt/cfx_bytestring.cpp | |
parent | 5b2092a1ec59077b430bd2cab91554cad2eb5128 (diff) | |
download | pdfium-f2ca50ffa2d26a6c023add24e92adbe6b28bfcc9.tar.xz |
Avoid double va_list traversal in CFX_WideString::FormatV
Speculative fix for bug. Also remove FX_VA_COPY as va_copy should
be fine on all ports nowdays (we think).
Bug: 763965
Change-Id: I5c321d5624d00b3b2f262ec599e4382f02b744ff
Reviewed-on: https://pdfium-review.googlesource.com/13790
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_bytestring.cpp')
-rw-r--r-- | core/fxcrt/cfx_bytestring.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp index 20497ecc32..073591a5ab 100644 --- a/core/fxcrt/cfx_bytestring.cpp +++ b/core/fxcrt/cfx_bytestring.cpp @@ -473,20 +473,22 @@ CFX_ByteString CFX_ByteString::FormatInteger(int i) { } void CFX_ByteString::FormatV(const char* pFormat, va_list argList) { - va_list argListSave; - FX_VA_COPY(argListSave, argList); - FX_STRSIZE nMaxLen = vsnprintf(nullptr, 0, pFormat, argList); + va_list argListCopy; + va_copy(argListCopy, argList); + FX_STRSIZE nMaxLen = vsnprintf(nullptr, 0, pFormat, argListCopy); + va_end(argListCopy); if (nMaxLen > 0) { GetBuffer(nMaxLen); if (m_pData) { // In the following two calls, there's always space in the buffer for // a terminating NUL that's not included in nMaxLen. memset(m_pData->m_String, 0, nMaxLen + 1); - vsnprintf(m_pData->m_String, nMaxLen + 1, pFormat, argListSave); + va_copy(argListCopy, argList); + vsnprintf(m_pData->m_String, nMaxLen + 1, pFormat, argListCopy); + va_end(argListCopy); ReleaseBuffer(GetStringLength()); } } - va_end(argListSave); } void CFX_ByteString::Format(const char* pFormat, ...) { |