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

Side by Side Diff: src/d8.cc

Issue 8898021: Fix crash in d8 when external array ctor hits stack overflow (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments, simplified code Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-100859.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 element_size == 8); 289 element_size == 8);
290 if (args.Length() != 1) { 290 if (args.Length() != 1) {
291 return ThrowException( 291 return ThrowException(
292 String::New("Array constructor needs one parameter.")); 292 String::New("Array constructor needs one parameter."));
293 } 293 }
294 static const int kMaxLength = 0x3fffffff; 294 static const int kMaxLength = 0x3fffffff;
295 #ifndef V8_SHARED 295 #ifndef V8_SHARED
296 ASSERT(kMaxLength == i::ExternalArray::kMaxLength); 296 ASSERT(kMaxLength == i::ExternalArray::kMaxLength);
297 #endif // V8_SHARED 297 #endif // V8_SHARED
298 size_t length = 0; 298 size_t length = 0;
299 TryCatch try_catch;
299 if (args[0]->IsUint32()) { 300 if (args[0]->IsUint32()) {
300 length = args[0]->Uint32Value(); 301 length = args[0]->Uint32Value();
301 } else { 302 } else {
302 Local<Number> number = args[0]->ToNumber(); 303 Local<Number> number = args[0]->ToNumber();
303 if (number.IsEmpty() || !number->IsNumber()) { 304 if (number.IsEmpty()) {
304 return ThrowException(String::New("Array length must be a number.")); 305 ASSERT(try_catch.HasCaught());
306 return try_catch.Exception();
305 } 307 }
306 int32_t raw_length = number->ToInt32()->Int32Value(); 308 ASSERT(number->IsNumber());
309 Local<Int32> int32 = number->ToInt32();
310 if (int32.IsEmpty()) {
311 if (try_catch.HasCaught()) {
312 return try_catch.Exception();
313 }
314 }
315 int32_t raw_length = int32->Int32Value();
316 if (try_catch.HasCaught()) {
317 return try_catch.Exception();
318 }
307 if (raw_length < 0) { 319 if (raw_length < 0) {
308 return ThrowException(String::New("Array length must not be negative.")); 320 return ThrowException(String::New("Array length must not be negative."));
309 } 321 }
310 if (raw_length > static_cast<int32_t>(kMaxLength)) { 322 if (raw_length > static_cast<int32_t>(kMaxLength)) {
311 return ThrowException( 323 return ThrowException(
312 String::New("Array length exceeds maximum length.")); 324 String::New("Array length exceeds maximum length."));
313 } 325 }
314 length = static_cast<size_t>(raw_length); 326 length = static_cast<size_t>(raw_length);
315 } 327 }
316 if (length > static_cast<size_t>(kMaxLength)) { 328 if (length > static_cast<size_t>(kMaxLength)) {
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 } 1393 }
1382 1394
1383 } // namespace v8 1395 } // namespace v8
1384 1396
1385 1397
1386 #ifndef GOOGLE3 1398 #ifndef GOOGLE3
1387 int main(int argc, char* argv[]) { 1399 int main(int argc, char* argv[]) {
1388 return v8::Shell::Main(argc, argv); 1400 return v8::Shell::Main(argc, argv);
1389 } 1401 }
1390 #endif 1402 #endif
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-100859.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698