Bug 521937 - Crash using js-ctypes open method with a wrong path [@PR_UnloadLibrary | mozilla::ctypes::Library::Finalize]. r=dwitte

This commit is contained in:
Makoto Kato 2009-10-14 12:57:42 +09:00
parent a00ded94a8
commit 84efb8602f
2 changed files with 11 additions and 4 deletions

View File

@ -73,6 +73,14 @@ Library::Create(JSContext* cx, jsval aPath)
if (!libraryObj)
return NULL;
// initialize the library
if (!JS_SetReservedSlot(cx, libraryObj, 0, PRIVATE_TO_JSVAL(NULL)))
return NULL;
// initialize our Function list to empty
if (!JS_SetReservedSlot(cx, libraryObj, 1, PRIVATE_TO_JSVAL(NULL)))
return NULL;
// attach API functions
if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
return NULL;
@ -117,10 +125,6 @@ Library::Create(JSContext* cx, jsval aPath)
if (!JS_SetReservedSlot(cx, libraryObj, 0, PRIVATE_TO_JSVAL(library)))
return NULL;
// initialize our Function list to empty
if (!JS_SetReservedSlot(cx, libraryObj, 1, PRIVATE_TO_JSVAL(NULL)))
return NULL;
return libraryObj;
}

View File

@ -109,6 +109,9 @@ function run_test()
obj.t = test_i8;
do_check_eq(test_i8(), 123);
do_check_eq(obj.t(), 123);
// bug 521937
do_check_throws(function () { var nolib = ctypes.open("notfoundlibrary.dll"); nolib.close(); }, Error);
}
function run_void_tests(library) {