Skip to content

Commit

Permalink
Memory allocation for WriteInto is not proper.
Browse files Browse the repository at this point in the history
Memory for WriteInto() should be greater than the url length,
As in the WriteInto() it reserve the memory of size 'length_with_null'
and then resize it to "length_with_null-1'
Chnage done to give memory 1 greater than the url length size.

BUG=417732

Review URL: https://codereview.chromium.org/599373003

Cr-Commit-Position: refs/heads/master@{#297102}
  • Loading branch information
deepak.m1 authored and Commit bot committed Sep 27, 2014
1 parent 89e4fb7 commit 64d8157
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pdf/pdfium/pdfium_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3394,8 +3394,8 @@ bool PDFiumEngineExports::RenderPDFPageToDC(const void* pdf_buffer,
base::string16 creator;
size_t buffer_bytes = FPDF_GetMetaText(doc, "Creator", NULL, 0);
if (buffer_bytes > 1) {
FPDF_GetMetaText(doc, "Creator", WriteInto(&creator, buffer_bytes),
buffer_bytes);
FPDF_GetMetaText(
doc, "Creator", WriteInto(&creator, buffer_bytes + 1), buffer_bytes);
}
bool use_bitmap = false;
if (StartsWith(creator, L"cairo", false))
Expand Down
4 changes: 2 additions & 2 deletions pdf/pdfium/pdfium_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ PDFiumPage::Area PDFiumPage::GetLinkTarget(
size_t buffer_size =
FPDFAction_GetURIPath(engine_->doc(), action, NULL, 0);
if (buffer_size > 1) {
void* data = WriteInto(&target->url, buffer_size);
void* data = WriteInto(&target->url, buffer_size + 1);
FPDFAction_GetURIPath(engine_->doc(), action, data, buffer_size);
}
}
Expand Down Expand Up @@ -389,7 +389,7 @@ void PDFiumPage::CalculateLinks() {
int url_length = FPDFLink_GetURL(links, i, NULL, 0);
if (url_length > 1) { // WriteInto needs at least 2 characters.
unsigned short* data =
reinterpret_cast<unsigned short*>(WriteInto(&url, url_length));
reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1));
FPDFLink_GetURL(links, i, data, url_length);
}
Link link;
Expand Down

0 comments on commit 64d8157

Please sign in to comment.