deinit z_stream properly if reading from input fails

Change-Id: Ifb057fbc5b7bc990f59d7938fa9853ce2cd94a31