actually, how about just adding after that line `while (SDL.rwops.length > 0 && SDL.rwops[SDL.rwops.length-1] === null) SDL.rwops.pop()`. That should in a simple way avoid it from getting too large, in most reasonable use cases