So I\'m trying to create a flood fill algorithm and I keep getting a recursion error with this. The algorithm seems to have infinite recursion and I cannot pinpoint why. I
Instead of recursion, why not flood-fill in a depth-first manner? Recursion uses an implicit stack anyway so you've nothing to lose.
And yes, as pointed out in the comments, you should be checking for x and y being out of bounds.