summaryrefslogtreecommitdiff
path: root/fxjs/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-17 16:41:28 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-17 16:41:28 +0000
commitb7973bb5a0ad2f83a71362d601a928964559004a (patch)
tree74acc13d4e542b668f727c323a1ccc97461ec55f /fxjs/xfa
parent8cfcb7da37352b22517892e6eabcedb77676cdf7 (diff)
downloadpdfium-b7973bb5a0ad2f83a71362d601a928964559004a.tar.xz
Reland "Return pdfium::span<wchar_t> from WideString::GetBuffer().""
This reverts commit 0d32b8fda53e02c1036d39f7290d4f59f2b58ca4. Restore behaviour on trunk. TBR: dsinclair@chromium.org Change-Id: Ia867f09ae9d2885595c4d9b300a058431dfd84f2 Reviewed-on: https://pdfium-review.googlesource.com/30811 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-rw-r--r--fxjs/xfa/cjx_hostpseudomodel.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 6ca431e78d..fe26d3161d 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -29,16 +29,18 @@ int32_t FilterName(const WideStringView& wsExpression,
if (nStart >= iLength)
return iLength;
- wchar_t* pBuf = wsFilter.GetBuffer(iLength - nStart);
int32_t nCount = 0;
- const wchar_t* pSrc = wsExpression.unterminated_c_str();
- wchar_t wCur;
- while (nStart < iLength) {
- wCur = pSrc[nStart++];
- if (wCur == ',')
- break;
-
- pBuf[nCount++] = wCur;
+ {
+ // Span's lifetime must end before ReleaseBuffer() below.
+ pdfium::span<wchar_t> pBuf = wsFilter.GetBuffer(iLength - nStart);
+ const wchar_t* pSrc = wsExpression.unterminated_c_str();
+ while (nStart < iLength) {
+ wchar_t wCur = pSrc[nStart++];
+ if (wCur == ',')
+ break;
+
+ pBuf[nCount++] = wCur;
+ }
}
wsFilter.ReleaseBuffer(nCount);
wsFilter.Trim();