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

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

Issue 1195363002: Cleanup: Do not check pointers before deleting them, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 5 years, 5 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 "../../core/include/fpdfdoc/fpdf_doc.h" 7 #include "../../core/include/fpdfdoc/fpdf_doc.h"
8 #include "../../core/include/fpdftext/fpdf_text.h" 8 #include "../../core/include/fpdftext/fpdf_text.h"
9 #include "../../public/fpdf_text.h" 9 #include "../../public/fpdf_text.h"
10 10
11 #ifdef _WIN32 11 #ifdef _WIN32
12 #include <tchar.h> 12 #include <tchar.h>
13 #endif 13 #endif
14 14
15 // jabdelmalek: commented out to build on Linux. Not used. 15 // jabdelmalek: commented out to build on Linux. Not used.
16 // extern HANDLE g_hModule; 16 // extern HANDLE g_hModule;
17 17
18 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) 18 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page)
19 { 19 {
20 if (!page) return NULL; 20 if (!page) return NULL;
21 IPDF_TextPage* textpage=NULL; 21 IPDF_TextPage* textpage=NULL;
22 CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument); 22 CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument);
23 textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.IsDirect ionR2L()); 23 textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.IsDirect ionR2L());
24 textpage->ParseTextPage(); 24 textpage->ParseTextPage();
25 return textpage; 25 return textpage;
26 } 26 }
27 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) 27 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page)
28 { 28 {
29 » if (text_page){ 29 delete (IPDF_TextPage*)text_page;
30 » » IPDF_TextPage* textpage=(IPDF_TextPage*)text_page; 30 text_page = NULL;
Tom Sepez 2015/07/16 17:22:44 nit: pointless assignment, not passed as ref.
Lei Zhang 2015/07/16 21:20:48 Done.
31 » » delete textpage;
32 » » text_page=NULL;
33 » }
34 } 31 }
35 DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page) 32 DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page)
36 { 33 {
37 if (!text_page) return -1; 34 if (!text_page) return -1;
38 IPDF_TextPage* textpage=(IPDF_TextPage*)text_page; 35 IPDF_TextPage* textpage=(IPDF_TextPage*)text_page;
39 return textpage->CountChars(); 36 return textpage->CountChars();
40 } 37 }
41 DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index) 38 DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index)
42 { 39 {
43 if (!text_page) return -1; 40 if (!text_page) return -1;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (rect_index >= 0 && rect_index < rectArray.GetSize()) { 236 if (rect_index >= 0 && rect_index < rectArray.GetSize()) {
240 CFX_FloatRect rect=rectArray.GetAt(rect_index); 237 CFX_FloatRect rect=rectArray.GetAt(rect_index);
241 *left=rect.left; 238 *left=rect.left;
242 *right=rect.right; 239 *right=rect.right;
243 *top=rect.top; 240 *top=rect.top;
244 *bottom=rect.bottom; 241 *bottom=rect.bottom;
245 } 242 }
246 } 243 }
247 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) 244 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page)
248 { 245 {
249 » if (!link_page) return; 246 delete (IPDF_LinkExtract*)link_page;
250 » IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; 247 link_page = NULL;
Tom Sepez 2015/07/16 17:22:44 nit: ditto.
Lei Zhang 2015/07/16 21:20:48 Done.
251 » delete pageLink;
252 » pageLink =NULL;
253 } 248 }
254 249
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698