Harden decompress code against memory stress

Under severe memory pressure the decompress code can fail to setup
properly. Add checks before dereferencing pointers.