Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: pdf/pdfium/pdfium_range.cc

Issue 848073003: PDF: Yet another stab at getting WriteInto() buffer sizes correct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/pdfium/pdfium_page.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_range.cc
diff --git a/pdf/pdfium/pdfium_range.cc b/pdf/pdfium/pdfium_range.cc
index 226d51284136ebb35fe0cd3b93c015da702224b9..b0474fc7d679351c70ce25cf6d068264d061b4ce 100644
--- a/pdf/pdfium/pdfium_range.cc
+++ b/pdf/pdfium/pdfium_range.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/strings/string_util.h"
+#include "pdf/pdfium/pdfium_api_string_buffer_adapter.h"
namespace chrome_pdf {
@@ -66,15 +67,13 @@ base::string16 PDFiumRange::GetText() {
}
if (count > 0) {
+ PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&rv,
+ count,
+ false);
unsigned short* data =
- reinterpret_cast<unsigned short*>(WriteInto(&rv, count + 1));
- // |written| includes the trailing terminator, so get rid of the trailing
- // NUL character by calling resize().
+ reinterpret_cast<unsigned short*>(api_string_adapter.GetData());
int written = FPDFText_GetText(page_->GetTextPage(), index, count, data);
- if (written < 1)
- rv.resize(0);
- else
- rv.resize(written - 1);
+ api_string_adapter.Close(written);
}
return rv;
« no previous file with comments | « pdf/pdfium/pdfium_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698