Skip to content

Commit 3a7df3b

Browse files
committed
SY-4149: Add length guard
1 parent abe968e commit 3a7df3b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

pluto/src/telem/aether/convertSeries.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ describe("convertSeriesToSupportedGL", () => {
9292
const result = convertSeriesToSupportedGL(series, offset);
9393
expect(result.sampleOffset).toBe(offset);
9494
});
95+
96+
it("does not throw on a zero-length bigint series with no explicit offset", () => {
97+
const series = new Series({
98+
data: new BigInt64Array(0),
99+
dataType: DataType.INT64,
100+
});
101+
const result = convertSeriesToSupportedGL(series);
102+
expect(result.dataType.equals(DataType.FLOAT32)).toBe(true);
103+
expect(result).toHaveLength(0);
104+
});
95105
});
96106

97107
describe("resolveGLDataType", () => {

pluto/src/telem/aether/convertSeries.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const convertSeriesToSupportedGL = (
2929
): Series => {
3030
if (series.dataType.isVariable || series.dataType.equals(DataType.UINT8))
3131
return series;
32-
if (offset == null && series.dataType.usesBigInt) offset = BigInt(series.data[0]);
32+
if (offset == null && series.dataType.usesBigInt && series.length > 0)
33+
offset = BigInt(series.data[0]);
3334
return series.convert(DataType.FLOAT32, offset);
3435
};
3536

0 commit comments

Comments
 (0)