Added check to avoid SIGFPE

Change-Id: I65358d98ae2b5e2d6125ccfdcbcd4d6fcc4b7126