Index: pdf/pdfium/pdfium_range.cc |
diff --git a/pdf/pdfium/pdfium_range.cc b/pdf/pdfium/pdfium_range.cc |
index 226d51284136ebb35fe0cd3b93c015da702224b9..c941d8e905fd6db99fadda0e04bbc57fb072a799 100644 |
--- a/pdf/pdfium/pdfium_range.cc |
+++ b/pdf/pdfium/pdfium_range.cc |
@@ -71,10 +71,12 @@ base::string16 PDFiumRange::GetText() { |
// |written| includes the trailing terminator, so get rid of the trailing |
// NUL character by calling resize(). |
int written = FPDFText_GetText(page_->GetTextPage(), index, count, data); |
- if (written < 1) |
- rv.resize(0); |
- else |
+ if (written > 0) { |
+ DCHECK_EQ(L'\0', rv[written - 1]); |
rv.resize(written - 1); |
+ } else { |
+ rv.clear(); |
+ } |
} |
return rv; |