[BUG #8760] In this case target was undefined. But the check only checks for null

(cherry picked from commit 4de85e2c650dd6bd0f5cdd4b56472f835427c4ca)