check arguments

Change-Id: I62f5abfe8f954f9825befcad589ded09ae8f7700
avoid out-of-bounds read

Change-Id: I5510b80b9c6d1512f2e6e8bb25f48fb0bcded515
nothing to do here if there's no bitmap data to read

Change-Id: I07d1540d44dc97d7fbb88db363123cb28b7d812d
avoid out-of-bounds read

Change-Id: I6b43ce6e7160789bdd99aabf8632bfc3431d4b7d
deinit z_stream properly if reading from input fails

Change-Id: I5a2ce38daf8f251029ccf8c1458025f950fe2af2