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

Unified Diff: pdf/pdfium/pdfium_engine.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_api_string_buffer_adapter.cc ('k') | pdf/pdfium/pdfium_page.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 228a8899cc4f5436c1ca4b7f7015ce40e68d05da..87f8d65dc90e3a09695495146564febe52b6ce6c 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "pdf/draw_utils.h"
+#include "pdf/pdfium/pdfium_api_string_buffer_adapter.h"
#include "pdf/pdfium/pdfium_mem_buffer_file_read.h"
#include "pdf/pdfium/pdfium_mem_buffer_file_write.h"
#include "ppapi/c/pp_errors.h"
@@ -2068,18 +2069,16 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term,
if (text_length <= 0)
return;
+ PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&page_text,
+ text_length,
+ false);
unsigned short* data =
- reinterpret_cast<unsigned short*>(WriteInto(&page_text, text_length + 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(pages_[current_page]->GetTextPage(),
character_to_start_searching_from,
text_length,
data);
- if (written < 1)
- page_text.resize(0);
- else
- page_text.resize(written - 1);
+ api_string_adapter.Close(written);
std::vector<PDFEngine::Client::SearchStringResult> results;
client_->SearchString(
« no previous file with comments | « pdf/pdfium/pdfium_api_string_buffer_adapter.cc ('k') | pdf/pdfium/pdfium_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698