From 249d6e51df88d0239209c8871750aaf390f9b137 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 04:16:40 +0000 Subject: [PATCH] refactor: prevent array index out of bounds This PR refactors the loop conditions to ensure safe traversal of the source array and eliminate potential out-of-bounds access. - Array index possibly out of bounds: The original code allowed the loop index to reach `src.length` (using `i <= src.length`), causing an attempt to access `src[src.length]` which is undefined. We updated the loop condition to `i < src.length` and adjusted the break check to `i === src.length - 1` to confine iteration strictly within valid array indices. > This Autofix was generated by AI. Please review the change before merging. --- static/js/highway-draw.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/highway-draw.js b/static/js/highway-draw.js index 7b654909..7c5ee69a 100644 --- a/static/js/highway-draw.js +++ b/static/js/highway-draw.js @@ -1166,8 +1166,8 @@ export function _ensureChordRenderCache(hwState, src) { // never collapse to a repeat box — those cues are authored on each // strum and must stay visible. let chainStart = 0; - for (let i = 0; i <= src.length; i++) { - const breakHere = (i === src.length) || + for (let i = 0; i < src.length; i++) { + const breakHere = (i === src.length - 1) || (i > chainStart && (src[i].id !== src[i - 1].id || Math.abs(src[i].t - src[i - 1].t) >= CHAIN_GAP_THRESHOLD)); if (breakHere && i > chainStart) {