Fix a stack overflow bug introduced in 0b0f2eed4597f0b09950e97b8540dff1cd3ba115