Added missing checks
Merge pull request #9116 from malinoff/fix-#6870

Fix for issue #6870