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

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: Tabify files 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
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 = 0;
166 » » while (findwhat[len]) len++;
palmer 2014/07/12 00:54:39 wcslen?
Bo Xu 2014/07/12 05:18:04 Done.
167 » » textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, le n),flags,start_index);
166 } 168 }
167 catch (...) 169 catch (...)
168 { 170 {
169 if (textpageFind) 171 if (textpageFind)
170 delete textpageFind; 172 delete textpageFind;
171 return NULL; 173 return NULL;
172 } 174 }
173 return textpageFind; 175 return textpageFind;
174 } 176 }
175 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle) 177 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; 271 *bottom=rect.bottom;
270 } 272 }
271 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) 273 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page)
272 { 274 {
273 if (!link_page) return; 275 if (!link_page) return;
274 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; 276 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page;
275 delete pageLink; 277 delete pageLink;
276 pageLink =NULL; 278 pageLink =NULL;
277 } 279 }
278 280
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698