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

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp

Issue 1192743004: Cleanup: Do not check pointers before deleting them. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: 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
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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../fpdf_page/pageint.h" 9 #include "../fpdf_page/pageint.h"
10 #include <limits.h> 10 #include <limits.h>
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); 1037 FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
1038 nStemV = pFont->GetGlyphWidth(glyph); 1038 nStemV = pFont->GetGlyphWidth(glyph);
1039 for (size_t i = 1; i < count; i++) { 1039 for (size_t i = 1; i < count; i++) {
1040 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]); 1040 glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
1041 int width = pFont->GetGlyphWidth(glyph); 1041 int width = pFont->GetGlyphWidth(glyph);
1042 if (width > 0 && width < nStemV) { 1042 if (width > 0 && width < nStemV) {
1043 nStemV = width; 1043 nStemV = width;
1044 } 1044 }
1045 } 1045 }
1046 } 1046 }
1047 if (pEncoding) { 1047 delete pEncoding;
1048 delete pEncoding;
1049 }
1050 pFontDesc->SetAtInteger("StemV", nStemV); 1048 pFontDesc->SetAtInteger("StemV", nStemV);
1051 AddIndirectObject(pFontDesc); 1049 AddIndirectObject(pFontDesc);
1052 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); 1050 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
1053 return LoadFont(pBaseDict); 1051 return LoadFont(pBaseDict);
1054 } 1052 }
1055 static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages, 1053 static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages,
1056 int nPagesToGo, CPDF_Dictionary* pPage, FX_BOOL b Insert, CFX_PtrArray& stackList) 1054 int nPagesToGo, CPDF_Dictionary* pPage, FX_BOOL b Insert, CFX_PtrArray& stackList)
1057 { 1055 {
1058 CPDF_Array* pKidList = pPages->GetArray("Kids"); 1056 CPDF_Array* pKidList = pPages->GetArray("Kids");
1059 if (!pKidList) { 1057 if (!pKidList) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, const CFX_ByteStringC& nam e) 1172 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, const CFX_ByteStringC& nam e)
1175 { 1173 {
1176 if (pPageDict->KeyExist(name)) { 1174 if (pPageDict->KeyExist(name)) {
1177 return; 1175 return;
1178 } 1176 }
1179 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); 1177 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name);
1180 if (pObj) { 1178 if (pObj) {
1181 pPageDict->SetAt(name, pObj->Clone()); 1179 pPageDict->SetAt(name, pObj->Clone());
1182 } 1180 }
1183 } 1181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698