diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/cxfa_textlayout.cpp | 28 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_localevalue.cpp | 44 |
2 files changed, 38 insertions, 34 deletions
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index e360c16dde..5359a340e5 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -911,21 +911,23 @@ void CXFA_TextLayout::ProcessText(WideString& wsText) { if (iLen == 0) return; - wchar_t* psz = wsText.GetBuffer(iLen); int32_t iTrimLeft = 0; - wchar_t wch = 0, wPrev = 0; - for (int32_t i = 0; i < iLen; i++) { - wch = psz[i]; - if (wch < 0x20) - wch = 0x20; - if (wch == 0x20 && wPrev == 0x20) - continue; - - wPrev = wch; - psz[iTrimLeft++] = wch; + { + // Span's lifetime must end before ReleaseBuffer() below. + pdfium::span<wchar_t> psz = wsText.GetBuffer(iLen); + wchar_t wPrev = 0; + for (int32_t i = 0; i < iLen; i++) { + wchar_t wch = psz[i]; + if (wch < 0x20) + wch = 0x20; + if (wch == 0x20 && wPrev == 0x20) + continue; + + wPrev = wch; + psz[iTrimLeft++] = wch; + } } - wsText.ReleaseBuffer(iLen); - wsText = wsText.Left(iTrimLeft); + wsText.ReleaseBuffer(iTrimLeft); } void CXFA_TextLayout::EndBreak(CFX_BreakType dwStatus, diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index 8ef67e5183..b129960f7d 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -682,32 +682,34 @@ void CXFA_LocaleValue::GetNumericFormat(WideString& wsFormat, int32_t nDecLen) { ASSERT(wsFormat.IsEmpty()); ASSERT(nIntLen >= -1 && nDecLen >= -1); - int32_t nTotalLen = (nIntLen >= 0 ? nIntLen : 2) + 1 + (nDecLen >= 0 ? nDecLen : 2) + (nDecLen == 0 ? 0 : 1); - wchar_t* lpBuf = wsFormat.GetBuffer(nTotalLen); - int32_t nPos = 0; - lpBuf[nPos++] = L's'; - - if (nIntLen == -1) { - lpBuf[nPos++] = L'z'; - lpBuf[nPos++] = L'*'; - } else { - while (nIntLen) { + { + // Span's lifetime must end before ReleaseBuffer() below. + pdfium::span<wchar_t> lpBuf = wsFormat.GetBuffer(nTotalLen); + int32_t nPos = 0; + lpBuf[nPos++] = L's'; + + if (nIntLen == -1) { lpBuf[nPos++] = L'z'; - nIntLen--; + lpBuf[nPos++] = L'*'; + } else { + while (nIntLen) { + lpBuf[nPos++] = L'z'; + nIntLen--; + } } - } - if (nDecLen != 0) { - lpBuf[nPos++] = L'.'; - } - if (nDecLen == -1) { - lpBuf[nPos++] = L'z'; - lpBuf[nPos++] = L'*'; - } else { - while (nDecLen) { + if (nDecLen != 0) { + lpBuf[nPos++] = L'.'; + } + if (nDecLen == -1) { lpBuf[nPos++] = L'z'; - nDecLen--; + lpBuf[nPos++] = L'*'; + } else { + while (nDecLen) { + lpBuf[nPos++] = L'z'; + nDecLen--; + } } } wsFormat.ReleaseBuffer(nTotalLen); |