tools/tiffdither.c: check memory allocations to avoid writing to
NULL pointer. Also check multiplication overflow. Fixes #2501,
CVE-2014-8128. Derived from patch by Petr Gajdos.
Reported by: naddy
Obtained from: https://github.com/vadz/libtiff/commit/147b2698c84004fe2da93c0fc7177a7c3797533d
MFH: 2015Q1