Skip to content

Commit 9cdb5f8

Browse files
committed
Fix: handle OTP28 uncompressed literals
Afaik packbeam is being unified, so this is interim quickfix. Signed-off-by: Peter M <[email protected]>
1 parent 27ddd7d commit 9cdb5f8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/packbeam.ex

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ defmodule ExAtomVM.PackBEAM do
1616

1717
defp uncompress_literals(chunks) do
1818
with {~c"LitT", litt} <- List.keyfind(chunks, ~c"LitT", 0),
19-
<<_header::binary-size(4), data::binary>> <- litt do
20-
litu = :zlib.uncompress(data)
21-
19+
litu <- maybe_uncompress_literals(litt) do
2220
chunks
2321
|> List.keyreplace(~c"LitT", 0, {~c"LitU", litu})
2422
else
@@ -27,6 +25,19 @@ defmodule ExAtomVM.PackBEAM do
2725
end
2826
end
2927

28+
defp maybe_uncompress_literals(chunk) do
29+
case chunk do
30+
<<0::32, data::binary>> ->
31+
data
32+
33+
<<_size::4-binary, data::binary>> ->
34+
:zlib.uncompress(data)
35+
36+
_ ->
37+
nil
38+
end
39+
end
40+
3041
defp strip(chunks) do
3142
Enum.filter(chunks, fn {chunk_name, _} ->
3243
MapSet.member?(@allowed_chunks, chunk_name)

0 commit comments

Comments
 (0)