Add replace null check for infinite loop

This test checks for the infinite loop bug in a memory-source system.