The first thing that I would check is that you are not exceeding any array bounds and writing on memory outside of the array