Core/Scripts: Fix possible crash

Fix possible NULL dereference crash spotted by Coverity.