You need to check if `JS_NewUCStringCopyN` returned null.