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

Side by Side Diff: fpdfsdk/src/javascript/PublicMethods.cpp

Issue 1411663013: Cleanup: Remove some NULL checks in fpdfsdk. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: even simplier? Created 5 years, 1 month 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/fsdk_baseform.cpp ('k') | 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 #include "PublicMethods.h" 7 #include "PublicMethods.h"
8 8
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment.
10 #include "../../include/javascript/IJavaScript.h" 10 #include "../../include/javascript/IJavaScript.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 CFX_WideString wsStr = val.ToCFXWideString(); 360 CFX_WideString wsStr = val.ToCFXWideString();
361 CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr); 361 CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
362 const char* p = (const char*)t; 362 const char* p = (const char*)t;
363 363
364 int ch = ','; 364 int ch = ',';
365 int nIndex = 0; 365 int nIndex = 0;
366 366
367 while (*p) { 367 while (*p) {
368 const char* pTemp = strchr(p, ch); 368 const char* pTemp = strchr(p, ch);
369 if (pTemp == NULL) { 369 if (!pTemp) {
370 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(p).c_str())); 370 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(p).c_str()));
371 break; 371 break;
372 } else { 372 }
373 char* pSub = new char[pTemp - p + 1];
374 strncpy(pSub, p, pTemp - p);
375 *(pSub + (pTemp - p)) = '\0';
376 373
377 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(pSub).c_str())); 374 char* pSub = new char[pTemp - p + 1];
378 delete[] pSub; 375 strncpy(pSub, p, pTemp - p);
376 *(pSub + (pTemp - p)) = '\0';
379 377
380 nIndex++; 378 StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(pSub).c_str()));
381 p = ++pTemp; 379 delete[] pSub;
382 } 380
381 nIndex++;
382 p = ++pTemp;
383 } 383 }
384 return StrArray; 384 return StrArray;
385 } 385 }
386 386
387 int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string, 387 int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string,
388 int nStart, 388 int nStart,
389 int& nSkip, 389 int& nSkip,
390 int nMaxStep) { 390 int nMaxStep) {
391 int nRet = 0; 391 int nRet = 0;
392 nSkip = 0; 392 nSkip = 0;
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 ASSERT(pContext != NULL); 1797 ASSERT(pContext != NULL);
1798 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); 1798 CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
1799 ASSERT(pEventHandler != NULL); 1799 ASSERT(pEventHandler != NULL);
1800 1800
1801 if (params.size() != 1) { 1801 if (params.size() != 1) {
1802 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1802 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1803 return FALSE; 1803 return FALSE;
1804 } 1804 }
1805 1805
1806 CFX_WideString swValue; 1806 CFX_WideString swValue;
1807 if (pEventHandler->m_pValue != NULL) 1807 if (pEventHandler->m_pValue)
1808 swValue = pEventHandler->Value(); 1808 swValue = pEventHandler->Value();
1809 1809
1810 if (pEventHandler->WillCommit()) { 1810 if (pEventHandler->WillCommit()) {
1811 vRet = swValue.c_str(); 1811 vRet = swValue.c_str();
1812 return TRUE; 1812 return TRUE;
1813 } 1813 }
1814 1814
1815 CFX_WideString prefix, postfix; 1815 CFX_WideString prefix, postfix;
1816 1816
1817 if (pEventHandler->SelStart() >= 0) 1817 if (pEventHandler->SelStart() >= 0)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); 2077 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str()));
2078 } 2078 }
2079 2079
2080 if (nums.GetLength() > 0) 2080 if (nums.GetLength() > 0)
2081 vRet = nums; 2081 vRet = nums;
2082 else 2082 else
2083 vRet.SetNull(); 2083 vRet.SetNull();
2084 2084
2085 return TRUE; 2085 return TRUE;
2086 } 2086 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_baseform.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698