Fix CVE-2014-0250

This patch fixes CVE-2014-0250 by checking width, height and bpp when
receiving a new pointer.
Merge pull request #1891 from hardening/CVE-2014-0250_1dot1

Fix for CVE 2014-0250