checkout: Fix overflow/recursion detection
checkout: Fix overflow/recursion detection

We were only adding to the array at the end, so in order to detect a
cyclic image (or just insane layering), use a stack counter.

cgwalters/dlayer-ostree,cgwalters/dlayer-ostree