free ram or read ram ?

Figure out the problem I was reading outside boundaries of array which was causing the problem but adding this function was solving the problem I cant understand why.