safety: audit and add missing exception checks to JSC::constructArray+constructEmptyArray (#20119)

This commit is contained in:
Meghan Denny
2025-05-31 19:05:02 -08:00
committed by GitHub
parent 5a025abddf
commit 284de53f26
72 changed files with 341 additions and 329 deletions

View File

@@ -37,7 +37,7 @@ pub fn myersDiff(
// moot since BunStrings with non-zero reference counds should never be
// dead.
if (actual.length() == 0 and expected.length() == 0) {
return JSC.JSValue.createEmptyArray(global, 0);
return try JSC.JSValue.createEmptyArray(global, 0);
}
const actual_encoding = actual.encoding();
@@ -112,9 +112,9 @@ fn diffLines(
}
fn diffListToJS(comptime T: type, global: *JSC.JSGlobalObject, diff_list: MyersDiff.DiffList(T)) bun.JSError!JSC.JSValue {
var array = JSC.JSValue.createEmptyArray(global, diff_list.items.len);
var array = try JSC.JSValue.createEmptyArray(global, diff_list.items.len);
for (diff_list.items, 0..) |*line, i| {
array.putIndex(global, @truncate(i), JSC.JSObject.createNullProto(line.*, global).toJS());
array.putIndex(global, @truncate(i), (try JSC.JSObject.createNullProto(line.*, global)).toJS());
}
return array;
}