It's nice that an LLM found a bug, but it's also trivially mitigated with the bounds safety sanitizer with virtually no overhead. Your regular reminder to build all production C projects with "-fsanitize=bounds -fsanitize-trap"
int aIdx[7]; // compiler knows the size of this array
...
int iCol; // if this should not be negative, why is this "int"?
...
aIdx[iCol] = i; // build with bound checking!