Add security check to validator function

CVE-2014-0061