summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_widestring.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-09-12 14:49:29 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-09-13 00:09:28 +0000
commitf2ca50ffa2d26a6c023add24e92adbe6b28bfcc9 (patch)
tree400be20cc2289c35d8bf61ba66ab56bdba14fa8b /core/fxcrt/cfx_widestring.cpp
parent5b2092a1ec59077b430bd2cab91554cad2eb5128 (diff)
downloadpdfium-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_widestring.cpp')
-rw-r--r--core/fxcrt/cfx_widestring.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp
index 24b7fb59d3..aadd1a29ed 100644
--- a/core/fxcrt/cfx_widestring.cpp
+++ b/core/fxcrt/cfx_widestring.cpp
@@ -665,17 +665,19 @@ bool CFX_WideString::TryVSWPrintf(FX_STRSIZE size,
void CFX_WideString::FormatV(const wchar_t* format, va_list argList) {
va_list argListCopy;
- FX_VA_COPY(argListCopy, argList);
+ va_copy(argListCopy, argList);
int maxLen = vswprintf(nullptr, 0, format, argListCopy);
va_end(argListCopy);
if (maxLen <= 0) {
+ va_copy(argListCopy, argList);
auto guess = GuessSizeForVSWPrintf(format, argListCopy);
+ va_end(argListCopy);
if (!guess.has_value())
return;
maxLen = pdfium::base::checked_cast<int>(guess.value());
}
while (maxLen < 32 * 1024) {
- FX_VA_COPY(argListCopy, argList);
+ va_copy(argListCopy, argList);
bool bSufficientBuffer =
TryVSWPrintf(static_cast<FX_STRSIZE>(maxLen), format, argListCopy);
va_end(argListCopy);