Return false instead of undefined in depthFirstSearchMatchTwoPaths bounds checks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -193,10 +193,10 @@ export const useMapPathStore = defineStore('mapPathStore', {
|
|||||||
},
|
},
|
||||||
depthFirstSearchMatchTwoPaths(curPath, curPathIndex, curButton, listIndex, nodeIndex) {
|
depthFirstSearchMatchTwoPaths(curPath, curPathIndex, curButton, listIndex, nodeIndex) {
|
||||||
if (listIndex >= curButton.length) { // Bounds check to prevent out-of-range access
|
if (listIndex >= curButton.length) { // Bounds check to prevent out-of-range access
|
||||||
return; // nodeIndex is the path index in the list after selecting one of the five buttons
|
return false; // nodeIndex is the path index in the list after selecting one of the five buttons
|
||||||
}
|
}
|
||||||
if (nodeIndex >= curButton[listIndex].length) { // Bounds check to prevent out-of-range access
|
if (nodeIndex >= curButton[listIndex].length) { // Bounds check to prevent out-of-range access
|
||||||
return; // The node index within this path in the list
|
return false; // The node index within this path in the list
|
||||||
}
|
}
|
||||||
// If `curPath` and `curButton[listIndex]` fully match
|
// If `curPath` and `curButton[listIndex]` fully match
|
||||||
if (curPathIndex === curPath.length || nodeIndex === curButton[listIndex].length) {
|
if (curPathIndex === curPath.length || nodeIndex === curButton[listIndex].length) {
|
||||||
@@ -205,7 +205,7 @@ export const useMapPathStore = defineStore('mapPathStore', {
|
|||||||
|
|
||||||
// Bounds check to prevent out-of-range access
|
// Bounds check to prevent out-of-range access
|
||||||
if (curPathIndex >= curPath.length || nodeIndex >= curButton[listIndex].length) {
|
if (curPathIndex >= curPath.length || nodeIndex >= curButton[listIndex].length) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodeLabel = curPath[curPathIndex].data('label');
|
const nodeLabel = curPath[curPathIndex].data('label');
|
||||||
|
|||||||
Reference in New Issue
Block a user