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

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

Issue 383563002: Fix an out-of-boundary issue for wide string (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add WStringLength function Created 6 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
« no previous file with comments | « fpdfsdk/src/fpdfdoc.cpp ('k') | fpdfsdk/src/javascript/Document.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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fpdftext.h" 8 #include "../include/fpdftext.h"
9 9
10 #ifdef _WIN32 10 #ifdef _WIN32
11 #include <tchar.h> 11 #include <tchar.h>
12 #endif 12 #endif
13 13
14 // jabdelmalek: commented out to build on Linux. Not used. 14 » // jabdelmalek: commented out to build on Linux. Not used.
15 // extern HANDLE g_hModule; 15 // extern HANDLE g_hModule;
16 16
17 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) 17 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page)
18 { 18 {
19 if (!page) return NULL; 19 if (!page) return NULL;
20 IPDF_TextPage* textpage=NULL; 20 IPDF_TextPage* textpage=NULL;
21 try 21 try
22 { 22 {
23 CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument); 23 CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument);
24 textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef. IsDirectionR2L()); 24 textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef. IsDirectionR2L());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 //Search 156 //Search
157 //-1 for end 157 //-1 for end
158 DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page,FPDF _WIDESTRING findwhat,unsigned long flags,int start_index) 158 DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page,FPDF _WIDESTRING findwhat,unsigned long flags,int start_index)
159 { 159 {
160 if (!text_page) return NULL; 160 if (!text_page) return NULL;
161 IPDF_TextPageFind* textpageFind=NULL; 161 IPDF_TextPageFind* textpageFind=NULL;
162 try 162 try
163 { 163 {
164 textpageFind=IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)t ext_page); 164 textpageFind=IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)t ext_page);
165 » » textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat),fl ags,start_index); 165 » » FX_STRSIZE len = CFX_WideString::WStringLength(findwhat);
166 » » textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, le n),flags,start_index);
166 } 167 }
167 catch (...) 168 catch (...)
168 { 169 {
169 if (textpageFind) 170 if (textpageFind)
170 delete textpageFind; 171 delete textpageFind;
171 return NULL; 172 return NULL;
172 } 173 }
173 return textpageFind; 174 return textpageFind;
174 } 175 }
175 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle) 176 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 *bottom=rect.bottom; 270 *bottom=rect.bottom;
270 } 271 }
271 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) 272 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page)
272 { 273 {
273 if (!link_page) return; 274 if (!link_page) return;
274 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; 275 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page;
275 delete pageLink; 276 delete pageLink;
276 pageLink =NULL; 277 pageLink =NULL;
277 } 278 }
278 279
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfdoc.cpp ('k') | fpdfsdk/src/javascript/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698