somethere in the route you are witing a buffer that is bigger than the allocated space...A buffer overrun
or wirting to the not-existing index of array... or something like that
it also explains randomness of the error - it occures when you trying to read the garbage, not when you put it there...