@@ -809,37 +809,41 @@ namespace osmium {
809809 case protozero::tag_and_type (FileFormat::Blob::optional_bytes_zstd_data, protozero::pbf_wire_type::length_delimited):
810810 throw osmium::pbf_error{" zstd blobs not supported" };
811811 default :
812- throw osmium::pbf_error{ " unknown compression " } ;
812+ pbf_blob. skip () ;
813813 }
814814 }
815815
816- if (!compressed_data.empty () && raw_size != 0 ) {
817- switch (use_compression) {
818- case pbf_compression::none:
819- break ;
820- case pbf_compression::zlib:
821- return osmium::io::detail::zlib_uncompress_string (
822- compressed_data.data (),
823- static_cast <unsigned long >(compressed_data.size ()), // NOLINT(google-runtime-int)
824- static_cast <unsigned long >(raw_size), // NOLINT(google-runtime-int)
825- output
826- );
827- case pbf_compression::lz4:
816+ if (compressed_data.empty ()) {
817+ throw osmium::pbf_error{" blob contains no data or unknown compression method" };
818+ }
819+
820+ if (raw_size == 0 ) {
821+ throw osmium::pbf_error{" missing raw_size in compressed blob" };
822+ }
823+
824+ switch (use_compression) {
825+ case pbf_compression::none:
826+ break ;
827+ case pbf_compression::zlib:
828+ return osmium::io::detail::zlib_uncompress_string (
829+ compressed_data.data (),
830+ static_cast <unsigned long >(compressed_data.size ()), // NOLINT(google-runtime-int)
831+ static_cast <unsigned long >(raw_size), // NOLINT(google-runtime-int)
832+ output
833+ );
834+ case pbf_compression::lz4:
828835#ifdef OSMIUM_WITH_LZ4
829- return osmium::io::detail::lz4_uncompress_string (
830- compressed_data.data (),
831- static_cast <unsigned long >(compressed_data.size ()), // NOLINT(google-runtime-int)
832- static_cast <unsigned long >(raw_size), // NOLINT(google-runtime-int)
833- output
834- );
836+ return osmium::io::detail::lz4_uncompress_string (
837+ compressed_data.data (),
838+ static_cast <unsigned long >(compressed_data.size ()), // NOLINT(google-runtime-int)
839+ static_cast <unsigned long >(raw_size), // NOLINT(google-runtime-int)
840+ output
841+ );
835842#else
836- break ;
843+ break ;
837844#endif
838- }
839- std::abort (); // should never be here
840845 }
841-
842- throw osmium::pbf_error{" blob contains no data" };
846+ std::abort (); // should never be here
843847 }
844848
845849 inline osmium::Box decode_header_bbox (const data_view& data) {
0 commit comments