Make sure id array are GC-protected. bug=351973 r=mrbkap sr=brendan

This commit is contained in:
igor.bukanov%gmail.com 2006-09-11 11:17:05 +00:00
Родитель ee901d127c
Коммит cde829c661
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -553,8 +553,10 @@ js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
return NULL; return NULL;
} }
map->table = table; map->table = table;
JS_KEEP_ATOMS(cx->runtime);
} }
/* From this point the control must flow either through out: or bad:. */
ida = NULL; ida = NULL;
if (map->depth == 0) { if (map->depth == 0) {
he = MarkSharpObjects(cx, obj, &ida); he = MarkSharpObjects(cx, obj, &ida);
@ -624,6 +626,7 @@ out:
bad: bad:
/* Clean up the sharpObjectMap table on outermost error. */ /* Clean up the sharpObjectMap table on outermost error. */
if (map->depth == 0) { if (map->depth == 0) {
JS_UNKEEP_ATOMS(cx->runtime);
map->sharpgen = 0; map->sharpgen = 0;
JS_HashTableDestroy(map->table); JS_HashTableDestroy(map->table);
map->table = NULL; map->table = NULL;
@ -640,6 +643,7 @@ js_LeaveSharpObject(JSContext *cx, JSIdArray **idap)
map = &cx->sharpObjectMap; map = &cx->sharpObjectMap;
JS_ASSERT(map->depth > 0); JS_ASSERT(map->depth > 0);
if (--map->depth == 0) { if (--map->depth == 0) {
JS_UNKEEP_ATOMS(cx->runtime);
map->sharpgen = 0; map->sharpgen = 0;
JS_HashTableDestroy(map->table); JS_HashTableDestroy(map->table);
map->table = NULL; map->table = NULL;