From 0186c1817bd1503051597dbcf0b032d4ff1277ab Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 1 Aug 2017 16:20:40 -0400 Subject: Remove support for negative params to ReleaseBuffer() This CL removes the default param value for this method, which was negative. It also adds in a method to get buffer lengths, so that the callsites can explictly passing in the length of the buffer if they were using the default value previously. BUG=pdfium:828 Change-Id: I0170771ee81970b8b601631015ab3e6e39fea8ea Reviewed-on: https://pdfium-review.googlesource.com/9790 Reviewed-by: Tom Sepez Commit-Queue: Ryan Harrison --- core/fxcrt/cfx_bytestring.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'core/fxcrt/cfx_bytestring.cpp') diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp index 6e01933682..5dcaf613a0 100644 --- a/core/fxcrt/cfx_bytestring.cpp +++ b/core/fxcrt/cfx_bytestring.cpp @@ -361,12 +361,10 @@ void CFX_ByteString::AllocBeforeWrite(FX_STRSIZE nNewLength) { } void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) { + ASSERT(nNewLength >= 0); if (!m_pData) return; - if (nNewLength == -1) - nNewLength = FXSYS_strlen(m_pData->m_String); - nNewLength = std::min(nNewLength, m_pData->m_nAllocLength); if (nNewLength == 0) { clear(); @@ -507,7 +505,7 @@ void CFX_ByteString::FormatV(const char* pFormat, va_list argList) { // 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); - ReleaseBuffer(); + ReleaseBuffer(GetStringLength()); } } va_end(argListSave); -- cgit v1.2.3