[QA] Fix up overzealous variable renaming.
Prevention of crashing in mapcache when tmp variable is NULL.

I haven't been able to trace why/when tmp becomes NULL,
 but at least one user has encountered this condition.
Thus add protection against deferencing a NULL pointer.