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

Side by Side 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: Fix accessibility code that can no longer occur 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 unified diff | Download patch
« pdf/pdfium/pdfium_page.cc ('K') | « pdf/pdfium/pdfium_page.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_range.h" 5 #include "pdf/pdfium/pdfium_range.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 9
10 namespace chrome_pdf { 10 namespace chrome_pdf {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 count *= -1; 64 count *= -1;
65 index -= count - 1; 65 index -= count - 1;
66 } 66 }
67 67
68 if (count > 0) { 68 if (count > 0) {
69 unsigned short* data = 69 unsigned short* data =
70 reinterpret_cast<unsigned short*>(WriteInto(&rv, count + 1)); 70 reinterpret_cast<unsigned short*>(WriteInto(&rv, count + 1));
71 // |written| includes the trailing terminator, so get rid of the trailing 71 // |written| includes the trailing terminator, so get rid of the trailing
72 // NUL character by calling resize(). 72 // NUL character by calling resize().
73 int written = FPDFText_GetText(page_->GetTextPage(), index, count, data); 73 int written = FPDFText_GetText(page_->GetTextPage(), index, count, data);
74 if (written < 1) 74 if (written > 0) {
75 rv.resize(0); 75 DCHECK_EQ(L'\0', rv[written - 1]);
76 else
77 rv.resize(written - 1); 76 rv.resize(written - 1);
77 } else {
78 rv.clear();
79 }
78 } 80 }
79 81
80 return rv; 82 return rv;
81 } 83 }
82 84
83 } // namespace chrome_pdf 85 } // namespace chrome_pdf
OLDNEW
« pdf/pdfium/pdfium_page.cc ('K') | « pdf/pdfium/pdfium_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698