Index: src/isolate.cc |
diff --git a/src/isolate.cc b/src/isolate.cc |
index 9ec3c9b2896b4bc294853e6cd82b929d55b51547..a4b311f6ecacd7d4b4a760931475bf4d9405c2ec 100644 |
--- a/src/isolate.cc |
+++ b/src/isolate.cc |
@@ -792,9 +792,8 @@ Object* Isolate::StackOverflow() { |
JSObject::GetDataProperty(Handle<JSObject>::cast(error), |
stackTraceLimit); |
if (!stack_trace_limit->IsNumber()) return heap()->exception(); |
- double dlimit = stack_trace_limit->Number(); |
- int limit = std::isnan(dlimit) ? 0 : static_cast<int>(dlimit); |
- |
+ int limit = FastD2IChecked(stack_trace_limit->Number()); |
+ if (limit < 0) limit = 0; |
Handle<JSArray> stack_trace = CaptureSimpleStackTrace( |
exception, factory()->undefined_value(), limit); |
JSObject::SetHiddenProperty(exception, |