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

Side by Side Diff: fpdfsdk/javascript/JS_Value.cpp

Issue 1929513002: Fix incorrect v8 TryCatch. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 #include "fpdfsdk/javascript/JS_Value.h" 7 #include "fpdfsdk/javascript/JS_Value.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 void CJS_Value::MaybeCoerceToNumber() { 145 void CJS_Value::MaybeCoerceToNumber() {
146 bool bAllowNaN = false; 146 bool bAllowNaN = false;
147 if (m_eType == VT_string) { 147 if (m_eType == VT_string) {
148 CFX_ByteString bstr = ToCFXByteString(); 148 CFX_ByteString bstr = ToCFXByteString();
149 if (bstr.GetLength() == 0) 149 if (bstr.GetLength() == 0)
150 return; 150 return;
151 if (bstr == "NaN") 151 if (bstr == "NaN")
152 bAllowNaN = true; 152 bAllowNaN = true;
153 } 153 }
154 v8::TryCatch(m_pJSRuntime->GetIsolate()); 154 v8::TryCatch try_catch(m_pJSRuntime->GetIsolate());
155 v8::MaybeLocal<v8::Number> maybeNum = 155 v8::MaybeLocal<v8::Number> maybeNum =
156 m_pValue->ToNumber(m_pJSRuntime->GetIsolate()->GetCurrentContext()); 156 m_pValue->ToNumber(m_pJSRuntime->GetIsolate()->GetCurrentContext());
157 if (maybeNum.IsEmpty()) 157 if (maybeNum.IsEmpty())
158 return; 158 return;
159 v8::Local<v8::Number> num = maybeNum.ToLocalChecked(); 159 v8::Local<v8::Number> num = maybeNum.ToLocalChecked();
160 if (std::isnan(num->Value()) && !bAllowNaN) 160 if (std::isnan(num->Value()) && !bAllowNaN)
161 return; 161 return;
162 m_pValue = num; 162 m_pValue = num;
163 m_eType = VT_number; 163 m_eType = VT_number;
164 } 164 }
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 for (size_t i = 0; i < nKeywords; ++i) { 893 for (size_t i = 0; i < nKeywords; ++i) {
894 const wchar_t* property = va_arg(ap, const wchar_t*); 894 const wchar_t* property = va_arg(ap, const wchar_t*);
895 v8::Local<v8::Value> v8Value = 895 v8::Local<v8::Value> v8Value =
896 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); 896 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property);
897 if (!v8Value->IsUndefined()) 897 if (!v8Value->IsUndefined())
898 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); 898 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown);
899 } 899 }
900 va_end(ap); 900 va_end(ap);
901 return result; 901 return result;
902 } 902 }
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