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

Side by Side Diff: fpdfsdk/include/fsdk_mgr.h

Issue 423233002: Speculative fix for uninitialized value in CFX_ByteString(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: whitespace, use nActualLength not nActualLength - 1. Created 6 years, 4 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 | « no previous file | no next file » | 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 #ifndef _FPDFSDK_MGR_H 7 #ifndef _FPDFSDK_MGR_H
8 #define _FPDFSDK_MGR_H 8 #define _FPDFSDK_MGR_H
9 9
10 #include "fsdk_common.h" 10 #include "fsdk_common.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void JS_appBeep(int nType) 166 void JS_appBeep(int nType)
167 { 167 {
168 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> app_beep) 168 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> app_beep)
169 { 169 {
170 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); 170 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType);
171 } 171 }
172 } 172 }
173 173
174 CFX_WideString JS_fieldBrowse() 174 CFX_WideString JS_fieldBrowse()
175 { 175 {
176 » » if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Field_browse) 176 » » if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform- >Field_browse)
177 { 177 {
178 » » » int nLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo- >m_pJsPlatform, NULL, 0); 178 » » » int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse( m_pInfo->m_pJsPlatform, NULL, 0);
179 » » » if(nLen <= 0) 179 » » » if (nRequiredLen <= 0)
180 return L""; 180 return L"";
181 » » » char* pbuff = new char[nLen]; 181
182 » » » if(pbuff) 182 » » » char* pbuff = new char[nRequiredLen];
183 » » » » memset(pbuff, 0, nLen); 183 » » » if (!pbuff)
184 » » » else»
185 return L""; 184 return L"";
186 » » » nLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_p JsPlatform, pbuff, nLen); 185
187 » » » CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); 186 » » » memset(pbuff, 0, nRequiredLen);
187 » » » int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(m_ pInfo->m_pJsPlatform, pbuff, nRequiredLen);
188 » » » if (nActualLen <= 0 || nActualLen > nRequiredLen)
189 » » » {
190 » » » » delete[] pbuff;
191 » » » » return L"";
192 » » » }
193 » » » CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ;
188 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 194 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
189 delete[] pbuff; 195 delete[] pbuff;
190 return wsRet; 196 return wsRet;
191 } 197 }
192 return L""; 198 return L"";
193 } 199 }
194 200
195 CFX_WideString JS_docGetFilePath() 201 CFX_WideString JS_docGetFilePath()
196 » {» » 202 » {
197 » » if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_getFilePath) 203 » » if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform- >Doc_getFilePath)
198 { 204 {
199 » » » int nLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pIn fo->m_pJsPlatform, NULL, 0); 205 » » » int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePa th(m_pInfo->m_pJsPlatform, NULL, 0);
200 » » » if(nLen <= 0) 206 » » » if (nRequiredLen <= 0)
201 return L""; 207 return L"";
202 » » » char* pbuff = new char[nLen]; 208
203 » » » if(pbuff) 209 » » » char* pbuff = new char[nRequiredLen];
204 » » » » memset(pbuff, 0, nLen); 210 » » » if (!pbuff)
205 » » » else
206 return L""; 211 return L"";
207 » » » nLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo-> m_pJsPlatform, pbuff, nLen); 212
208 » » » CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); 213 » » » memset(pbuff, 0, nRequiredLen);
214 » » » int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath (m_pInfo->m_pJsPlatform, pbuff, nRequiredLen);
215 » » » if (nActualLen <= 0 || nActualLen > nRequiredLen)
216 » » » {
217 » » » » delete[] pbuff;
218 » » » » return L"";
219 » » » }
220 » » » CFX_ByteString bsRet = CFX_ByteString(pbuff, nActualLen) ;
209 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 221 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
210 delete[] pbuff; 222 delete[] pbuff;
211 return wsRet; 223 return wsRet;
212 } 224 }
213 return L""; 225 return L"";
214 } 226 }
215 227
216 void JS_docSubmitForm(void* formData, int length, FX_LPCWSTR URL) 228 void JS_docSubmitForm(void* formData, int length, FX_LPCWSTR URL)
217 { 229 {
218 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_submitForm) 230 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform-> Doc_submitForm)
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 611 }
600 612
601 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); 613 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare);
602 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); 614 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare);
603 } 615 }
604 }; 616 };
605 617
606 618
607 #endif //_FPDFSDK_MGR_H 619 #endif //_FPDFSDK_MGR_H
608 620
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698