Is there any error?

Can any one point out if I made any error in the following code? This is the preprocessing step in KMP algorithm and is giving correct answer for my test cases. I just want to know whether the line, I have used a comment against, is correct or not.

My code