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

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

Issue 1142713005: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix missing FX_Alloc2D, check overflow on add, remove unused enum. 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 }
345 pGraphState->m_DashCount = dash_count; 342 pGraphState->m_DashCount = dash_count;
346 FX_DWORD i; 343 FX_DWORD i;
347 for (i = 0; i < pDashArray->GetCount(); i ++) { 344 for (i = 0; i < pDashArray->GetCount(); i ++) {
348 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); 345 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i);
349 } 346 }
350 if (i < dash_count) { 347 if (i < dash_count) {
351 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; 348 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1];
352 } 349 }
353 } else { 350 } else {
354 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); 351 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);
355 if (pGraphState->m_DashArray == NULL) {
356 return NULL;
357 }
358 pGraphState->m_DashCount = 2; 352 pGraphState->m_DashCount = 2;
359 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f ; 353 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f ;
360 } 354 }
361 } 355 }
362 CFX_FloatRect rect; 356 CFX_FloatRect rect;
363 GetRect(rect); 357 GetRect(rect);
364 width /= 2; 358 width /= 2;
365 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); 359 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify();
366 if (pPathData) { 360 if (pPathData) {
367 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 361 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
434 } 428 }
435 CPDF_GraphStateData graph_state; 429 CPDF_GraphStateData graph_state;
436 graph_state.m_LineWidth = width; 430 graph_state.m_LineWidth = width;
437 if (style_char == 'D') { 431 if (style_char == 'D') {
438 if (pDashArray) { 432 if (pDashArray) {
439 FX_DWORD dash_count = pDashArray->GetCount(); 433 FX_DWORD dash_count = pDashArray->GetCount();
440 if (dash_count % 2) { 434 if (dash_count % 2) {
441 dash_count ++; 435 dash_count ++;
442 } 436 }
443 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); 437 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
444 if (graph_state.m_DashArray == NULL) {
445 return ;
446 }
447 graph_state.m_DashCount = dash_count; 438 graph_state.m_DashCount = dash_count;
448 FX_DWORD i; 439 FX_DWORD i;
449 for (i = 0; i < pDashArray->GetCount(); i ++) { 440 for (i = 0; i < pDashArray->GetCount(); i ++) {
450 graph_state.m_DashArray[i] = pDashArray->GetNumber(i); 441 graph_state.m_DashArray[i] = pDashArray->GetNumber(i);
451 } 442 }
452 if (i < dash_count) { 443 if (i < dash_count) {
453 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; 444 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1];
454 } 445 }
455 } else { 446 } else {
456 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); 447 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2);
457 if (graph_state.m_DashArray == NULL) {
458 return ;
459 }
460 graph_state.m_DashCount = 2; 448 graph_state.m_DashCount = 2;
461 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; 449 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f;
462 } 450 }
463 } 451 }
464 CFX_FloatRect rect; 452 CFX_FloatRect rect;
465 GetRect(rect); 453 GetRect(rect);
466 CPDF_PathData path; 454 CPDF_PathData path;
467 width /= 2; 455 width /= 2;
468 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 456 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
469 int fill_type = 0; 457 int fill_type = 0;
(...skipping 30 matching lines...) Expand all
500 if (pIRT != m_pAnnotDict) { 488 if (pIRT != m_pAnnotDict) {
501 continue; 489 continue;
502 } 490 }
503 if (count == index) { 491 if (count == index) {
504 return pAnnot; 492 return pAnnot;
505 } 493 }
506 count ++; 494 count ++;
507 } 495 }
508 return NULL; 496 return NULL;
509 } 497 }
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