@@ -73,6 +73,7 @@ using v8::Handle;
73
73
using v8::HandleScope;
74
74
using v8::Isolate;
75
75
using v8::Local;
76
+ using v8::Maybe;
76
77
using v8::Number;
77
78
using v8::Object;
78
79
using v8::Persistent;
@@ -298,7 +299,13 @@ Local<Object> New(Environment* env, size_t length) {
298
299
length,
299
300
ArrayBufferCreationMode::kInternalized );
300
301
Local<Uint8Array> ui = Uint8Array::New (ab, 0 , length);
301
- ui->SetPrototype (env->buffer_prototype_object ());
302
+ Maybe<bool > mb =
303
+ ui->SetPrototype (env->context (), env->buffer_prototype_object ());
304
+ if (!mb.FromMaybe (false )) {
305
+ FatalError (" node::Buffer::New(Environment*, size_t)" ,
306
+ " Could not set Object prototype" );
307
+ UNREACHABLE ();
308
+ }
302
309
return scope.Escape (ui);
303
310
}
304
311
@@ -361,7 +368,13 @@ Local<Object> New(Environment* env, const char* data, size_t length) {
361
368
length,
362
369
ArrayBufferCreationMode::kInternalized );
363
370
Local<Uint8Array> ui = Uint8Array::New (ab, 0 , length);
364
- ui->SetPrototype (env->buffer_prototype_object ());
371
+ Maybe<bool > mb =
372
+ ui->SetPrototype (env->context (), env->buffer_prototype_object ());
373
+ if (!mb.FromMaybe (false )) {
374
+ FatalError (" node::Buffer::New(Environment*, char*, size_t)" ,
375
+ " Could not set Object prototype" );
376
+ UNREACHABLE ();
377
+ }
365
378
366
379
return scope.Escape (ui);
367
380
}
@@ -401,7 +414,14 @@ Local<Object> New(Environment* env,
401
414
402
415
Local<ArrayBuffer> ab = ArrayBuffer::New (env->isolate (), data, length);
403
416
Local<Uint8Array> ui = Uint8Array::New (ab, 0 , length);
404
- ui->SetPrototype (env->buffer_prototype_object ());
417
+ Maybe<bool > mb =
418
+ ui->SetPrototype (env->context (), env->buffer_prototype_object ());
419
+ if (!mb.FromMaybe (false )) {
420
+ FatalError (" node::Buffer::New(Environment*, char*, size_t,"
421
+ " FreeCallback, void*)" ,
422
+ " Could not set Object prototype" );
423
+ UNREACHABLE ();
424
+ }
405
425
CallbackInfo::New (env->isolate (), ui, callback, hint);
406
426
return scope.Escape (ui);
407
427
}
@@ -441,7 +461,13 @@ Local<Object> Use(Environment* env, char* data, size_t length) {
441
461
length,
442
462
ArrayBufferCreationMode::kInternalized );
443
463
Local<Uint8Array> ui = Uint8Array::New (ab, 0 , length);
444
- ui->SetPrototype (env->buffer_prototype_object ());
464
+ Maybe<bool > mb =
465
+ ui->SetPrototype (env->context (), env->buffer_prototype_object ());
466
+ if (!mb.FromMaybe (false )) {
467
+ FatalError (" node::Buffer::Use(Environment*, char*, size_t)" ,
468
+ " Could not set Object prototype" );
469
+ UNREACHABLE ();
470
+ }
445
471
return scope.Escape (ui);
446
472
}
447
473
@@ -473,8 +499,10 @@ void Create(const FunctionCallbackInfo<Value>& args) {
473
499
length,
474
500
ArrayBufferCreationMode::kInternalized );
475
501
Local<Uint8Array> ui = Uint8Array::New (ab, 0 , length);
476
- ui->SetPrototype (env->buffer_prototype_object ());
477
- args.GetReturnValue ().Set (ui);
502
+ Maybe<bool > mb =
503
+ ui->SetPrototype (env->context (), env->buffer_prototype_object ());
504
+ if (mb.FromMaybe (false ))
505
+ args.GetReturnValue ().Set (ui);
478
506
}
479
507
480
508
@@ -505,8 +533,10 @@ void Slice(const FunctionCallbackInfo<Value>& args) {
505
533
size_t size = end - start;
506
534
CHECK_GE (ab_c.ByteLength (), start + size);
507
535
Local<Uint8Array> ui = Uint8Array::New (ab, start, size);
508
- ui->SetPrototype (env->buffer_prototype_object ());
509
- args.GetReturnValue ().Set (ui);
536
+ Maybe<bool > mb =
537
+ ui->SetPrototype (env->context (), env->buffer_prototype_object ());
538
+ if (mb.FromMaybe (false ))
539
+ args.GetReturnValue ().Set (ui);
510
540
}
511
541
512
542
0 commit comments