Skip to content
This repository
Browse code

Fix some hazardous v8 handle type misuse

  • Loading branch information...
commit 62ec146a8dbb9098fb97d47732076862255841c9 1 parent 0afc402
Bert Belder authored September 05, 2012

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. 10  modules/js/cJs_posix.h
10  modules/js/cJs_posix.h
@@ -452,7 +452,7 @@ struct cJs : cJsBase {
452 452
 			return;
453 453
 
454 454
         cJs* pthis = (cJs*) parameter;
455  
-        Handle<Object> object = value->ToObject();
  455
+        Local<Object> object = value->ToObject();
456 456
 #ifdef O3_V8_GLUE
457 457
         iScr* scr = (iScr*) cast(object->GetInternalField(1));
458 458
 #else
@@ -488,7 +488,6 @@ struct cJs : cJsBase {
488 488
     { 
489 489
         o3_trace_hostglue("createObject"); 
490 490
 		HandleScope handle_scope;
491  
-        Persistent<Object> object;
492 491
 
493 492
 		tMap<iScr*, Handle<Object> >::Iter it = 
494 493
 			m_wrappers.find(scr);
@@ -497,8 +496,9 @@ struct cJs : cJsBase {
497 496
 			return it->val;
498 497
 		}	
499 498
         scr->addRef();
500  
-        object = Persistent<Object>::New(m_template->NewInstance());
501  
-        object.MakeWeak(this, finalize);
  499
+        Local<Object> object = m_template->NewInstance();
  500
+        Persistent<Object> handle = Persistent<Object>::New(object);
  501
+        handle.MakeWeak(this, finalize);
502 502
 #ifdef O3_V8_GLUE
503 503
 		object->SetInternalField(0, External::New(siCtx(this).ptr()));
504 504
 		object->SetInternalField(1, External::New(scr));
@@ -506,7 +506,7 @@ struct cJs : cJsBase {
506 506
 #else
507 507
 		object->SetInternalField(0, External::New(scr));
508 508
 #endif
509  
-		m_wrappers[scr] = object;
  509
+		m_wrappers[scr] = handle;
510 510
 		return handle_scope.Close(object);
511 511
     }
512 512
 

0 notes on commit 62ec146

Please sign in to comment.
Something went wrong with that request. Please try again.