events: don't inherit from Object.prototype

This commit safely allows event names that are named the same as
properties that are ordinarily inherited from Object.prototype such
as __proto__.

Fixes: https://github.com/nodejs/node/issues/728
PR-URL: https://github.com/nodejs/node/pull/6092
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Brian White committed 2016-04-18 21:45:26 -04:00
1 parent dba245f796
commit e38bade828
5 files changed
+52 -21

No files matched your search

+3 -1
View File
@@ -3228,7 +3228,9 @@ void SetupProcessObject(Environment* env,
env->SetMethod(process, "_setupDomainUse", SetupDomainUse);
// pre-set _events object for faster emit checks
process->Set(env->events_string(), Object::New(env->isolate()));
Local<Object> events_obj = Object::New(env->isolate());
events_obj->SetPrototype(env->context(), Null(env->isolate()));
process->Set(env->events_string(), events_obj);
}