Fix complex packing decode crash on trailing padding bits
consume_bits would crash with a MatchError when the remaining bitstring had fewer bits than the group width. Added a guard clause to stop consuming when insufficient bits remain, matching how wgrib2 handles trailing padding in packed data sections.
This commit is contained in:
parent
5a9359191f
commit
3749360a28
1 changed files with 1 additions and 1 deletions
|
|
@ -191,7 +191,7 @@ defmodule Microwaveprop.Weather.Grib2.ComplexPacking do
|
|||
end
|
||||
end
|
||||
|
||||
defp consume_bits(<<>>, _width, _gref, acc), do: acc
|
||||
defp consume_bits(bits, width, _gref, acc) when bit_size(bits) < width, do: acc
|
||||
|
||||
defp consume_bits(bits, width, gref, acc) do
|
||||
<<val::size(width)-unsigned-big, rest::bitstring>> = bits
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue