Crash setting accessor property

13 views
Skip to first unread message

J Decker

unread,
Feb 20, 2018, 6:46:49 AM2/20/18
to v8-u...@googlegroups.com

J Decker

unread,
Feb 20, 2018, 6:49:36 AM2/20/18
to v8-u...@googlegroups.com
(Oops hit enter too soon)

  node: '9.2.0',
  v8: '6.2.414.44-node.11',

Local<Object> c = Object::New( isolate );
c->SetAccessorProperty( String::NewFromUtf8( isolate, "password" )
, Local<Function>()
, Function::New( isolate, ControlObject::setEditFieldPassword )
, DontDelete );

This is an attempt to make a set-only property... SetAccessorProperty crashes on access of a NULL pointer. 



On Tue, Feb 20, 2018 at 3:46 AM, J Decker <d3c...@gmail.com> wrote:


Ben Noordhuis

unread,
Feb 20, 2018, 8:53:53 AM2/20/18
to v8-users
On Tue, Feb 20, 2018 at 12:49 PM, J Decker <d3c...@gmail.com> wrote:
> (Oops hit enter too soon)
>
> node: '9.2.0',
> v8: '6.2.414.44-node.11',
>
> Local<Object> c = Object::New( isolate );
> c->SetAccessorProperty( String::NewFromUtf8( isolate, "password" )
> , Local<Function>()
> , Function::New( isolate, ControlObject::setEditFieldPassword )
> , DontDelete );
>
> This is an attempt to make a set-only property... SetAccessorProperty
> crashes on access of a NULL pointer.

That's essentially "you can't do that" code. JS doesn't really have a
concept of setter-only properties and that's reflected in the C++ API.

You can emulate it with a getter that returns undefined, that mimics
the behavior of `Object.defineProperty(obj, key, { set: set })`.
Reply all
Reply to author
Forward
0 new messages