Fix CVE-2014-8767, CVE-2014-8768, CVE-2014-8769 and CVE-2014-9140

Signed-off-by: Pasi Sjöholm <pasi.sjoholm@jollamobile.com>