Fixed the incorrect caching of pointer reference in a loop containing function call