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

Side by Side Diff: core/src/fpdfdoc/doc_annot.cpp

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp ('k') | core/src/fpdftext/fpdf_text.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../../third_party/base/nonstd_unique_ptr.h"
8 #include "../../include/fpdfdoc/fpdf_doc.h" 8 #include "../../include/fpdfdoc/fpdf_doc.h"
9 #include "../../include/fpdfapi/fpdf_pageobj.h" 9 #include "../../include/fpdfapi/fpdf_pageobj.h"
10 10
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 pColorData->m_StrokeRGB = argb; 332 pColorData->m_StrokeRGB = argb;
333 pPathObject->m_bStroke = TRUE; 333 pPathObject->m_bStroke = TRUE;
334 pPathObject->m_FillType = 0; 334 pPathObject->m_FillType = 0;
335 if (style_char == 'D') { 335 if (style_char == 'D') {
336 if (pDashArray) { 336 if (pDashArray) {
337 FX_DWORD dash_count = pDashArray->GetCount(); 337 FX_DWORD dash_count = pDashArray->GetCount();
338 if (dash_count % 2) { 338 if (dash_count % 2) {
339 dash_count ++; 339 dash_count ++;
340 } 340 }
341 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); 341 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
342 if (pGraphState->m_DashArray == NULL) {
343 return NULL;
344 }
342 pGraphState->m_DashCount = dash_count; 345 pGraphState->m_DashCount = dash_count;
343 FX_DWORD i; 346 FX_DWORD i;
344 for (i = 0; i < pDashArray->GetCount(); i ++) { 347 for (i = 0; i < pDashArray->GetCount(); i ++) {
345 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); 348 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i);
346 } 349 }
347 if (i < dash_count) { 350 if (i < dash_count) {
348 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; 351 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1];
349 } 352 }
350 } else { 353 } else {
351 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); 354 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);
355 if (pGraphState->m_DashArray == NULL) {
356 return NULL;
357 }
352 pGraphState->m_DashCount = 2; 358 pGraphState->m_DashCount = 2;
353 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f ; 359 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f ;
354 } 360 }
355 } 361 }
356 CFX_FloatRect rect; 362 CFX_FloatRect rect;
357 GetRect(rect); 363 GetRect(rect);
358 width /= 2; 364 width /= 2;
359 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); 365 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify();
360 if (pPathData) { 366 if (pPathData) {
361 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 367 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 434 }
429 CPDF_GraphStateData graph_state; 435 CPDF_GraphStateData graph_state;
430 graph_state.m_LineWidth = width; 436 graph_state.m_LineWidth = width;
431 if (style_char == 'D') { 437 if (style_char == 'D') {
432 if (pDashArray) { 438 if (pDashArray) {
433 FX_DWORD dash_count = pDashArray->GetCount(); 439 FX_DWORD dash_count = pDashArray->GetCount();
434 if (dash_count % 2) { 440 if (dash_count % 2) {
435 dash_count ++; 441 dash_count ++;
436 } 442 }
437 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); 443 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
444 if (graph_state.m_DashArray == NULL) {
445 return ;
446 }
438 graph_state.m_DashCount = dash_count; 447 graph_state.m_DashCount = dash_count;
439 FX_DWORD i; 448 FX_DWORD i;
440 for (i = 0; i < pDashArray->GetCount(); i ++) { 449 for (i = 0; i < pDashArray->GetCount(); i ++) {
441 graph_state.m_DashArray[i] = pDashArray->GetNumber(i); 450 graph_state.m_DashArray[i] = pDashArray->GetNumber(i);
442 } 451 }
443 if (i < dash_count) { 452 if (i < dash_count) {
444 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; 453 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1];
445 } 454 }
446 } else { 455 } else {
447 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); 456 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2);
457 if (graph_state.m_DashArray == NULL) {
458 return ;
459 }
448 graph_state.m_DashCount = 2; 460 graph_state.m_DashCount = 2;
449 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; 461 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f;
450 } 462 }
451 } 463 }
452 CFX_FloatRect rect; 464 CFX_FloatRect rect;
453 GetRect(rect); 465 GetRect(rect);
454 CPDF_PathData path; 466 CPDF_PathData path;
455 width /= 2; 467 width /= 2;
456 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 468 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
457 int fill_type = 0; 469 int fill_type = 0;
(...skipping 30 matching lines...) Expand all
488 if (pIRT != m_pAnnotDict) { 500 if (pIRT != m_pAnnotDict) {
489 continue; 501 continue;
490 } 502 }
491 if (count == index) { 503 if (count == index) {
492 return pAnnot; 504 return pAnnot;
493 } 505 }
494 count ++; 506 count ++;
495 } 507 }
496 return NULL; 508 return NULL;
497 } 509 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp ('k') | core/src/fpdftext/fpdf_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698