Fix an out-of-bounds memory access error