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

Side by Side Diff: fpdfsdk/src/fpdfview.cpp

Issue 1192743004: Cleanup: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 6 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 | « fpdfsdk/src/fpdf_dataavail.cpp ('k') | fpdfsdk/src/fsdk_mgr.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 "../../core/include/fxcodec/fx_codec.h" 7 #include "../../core/include/fxcodec/fx_codec.h"
8 #include "../../core/include/fxcrt/fx_safe_types.h" 8 #include "../../core/include/fxcrt/fx_safe_types.h"
9 #include "../../public/fpdf_ext.h" 9 #include "../../public/fpdf_ext.h"
10 #include "../../public/fpdf_progressive.h" 10 #include "../../public/fpdf_progressive.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 BitBlt(dc, rect.left, rect.top, width, height, hMemDC, 0, 0, SRCCOPY); 475 BitBlt(dc, rect.left, rect.top, width, height, hMemDC, 0, 0, SRCCOPY);
476 SelectObject(hMemDC, hOldBitmap); 476 SelectObject(hMemDC, hOldBitmap);
477 DeleteDC(hMemDC); 477 DeleteDC(hMemDC);
478 478
479 #ifdef DEBUG_TRACE 479 #ifdef DEBUG_TRACE
480 CPDF_ModuleMgr::Get()->ReportError(999, "Finished screen rendering"); 480 CPDF_ModuleMgr::Get()->ReportError(999, "Finished screen rendering");
481 #endif 481 #endif
482 482
483 #endif 483 #endif
484 » if (bBackgroundAlphaNeeded) 484 if (bBackgroundAlphaNeeded) {
485 » { 485 delete pBitmap;
486 » » if (pBitmap) 486 pBitmap = NULL;
487 » » » delete pBitmap; 487 }
488 » » pBitmap = NULL; 488 delete pContext;
489 » } 489 pPage->RemovePrivateData((void*)1);
490 » delete pContext;
491 » pPage->RemovePrivateData((void*)1);
492 } 490 }
493 #endif 491 #endif
494 492
495 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, 493 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y,
496 int size_x, int size_y, int rota te, int flags) 494 int size_x, int size_y, int rota te, int flags)
497 { 495 {
498 if (bitmap == NULL || page == NULL) return; 496 if (bitmap == NULL || page == NULL) return;
499 CPDF_Page* pPage = (CPDF_Page*)page; 497 CPDF_Page* pPage = (CPDF_Page*)page;
500 498
501 499
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 653 }
656 654
657 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) 655 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap)
658 { 656 {
659 if (bitmap == NULL) return 0; 657 if (bitmap == NULL) return 0;
660 return ((CFX_DIBitmap*)bitmap)->GetPitch(); 658 return ((CFX_DIBitmap*)bitmap)->GetPitch();
661 } 659 }
662 660
663 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) 661 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap)
664 { 662 {
665 » if (bitmap == NULL) return; 663 delete (CFX_DIBitmap*)bitmap;
666 » delete (CFX_DIBitmap*)bitmap;
667 } 664 }
668 665
669 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_ x, int start_y, int size_x, int size_y, 666 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_ x, int start_y, int size_x, int size_y,
670 int rotate, int flags,FX_BOOL bN eedToRestore, IFSDK_PAUSE_Adapter * pause ) 667 int rotate, int flags,FX_BOOL bN eedToRestore, IFSDK_PAUSE_Adapter * pause )
671 { 668 {
672 CPDF_Page* pPage = (CPDF_Page*)page; 669 CPDF_Page* pPage = (CPDF_Page*)page;
673 if (pPage == NULL) return; 670 if (pPage == NULL) return;
674 671
675 if (!pContext->m_pOptions) 672 if (!pContext->m_pOptions)
676 pContext->m_pOptions = new CPDF_RenderOptions; 673 pContext->m_pOptions = new CPDF_RenderOptions;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 if (!buffer) { 857 if (!buffer) {
861 *buflen = len; 858 *buflen = len;
862 } else if (*buflen >= len) { 859 } else if (*buflen >= len) {
863 memcpy(buffer, utf16Name.c_str(), len); 860 memcpy(buffer, utf16Name.c_str(), len);
864 *buflen = len; 861 *buflen = len;
865 } else { 862 } else {
866 *buflen = -1; 863 *buflen = -1;
867 } 864 }
868 return (FPDF_DEST)pDestObj; 865 return (FPDF_DEST)pDestObj;
869 } 866 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_dataavail.cpp ('k') | fpdfsdk/src/fsdk_mgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698