From 9cdb5f848fee27b25ca011a25875dcc6448efbb3 Mon Sep 17 00:00:00 2001 From: Peter M Date: Sun, 10 Aug 2025 19:26:35 +0200 Subject: [PATCH] Fix: handle OTP28 uncompressed literals Afaik packbeam is being unified, so this is interim quickfix. Signed-off-by: Peter M --- lib/packbeam.ex | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/packbeam.ex b/lib/packbeam.ex index 7922f43..46d2176 100644 --- a/lib/packbeam.ex +++ b/lib/packbeam.ex @@ -16,9 +16,7 @@ defmodule ExAtomVM.PackBEAM do defp uncompress_literals(chunks) do with {~c"LitT", litt} <- List.keyfind(chunks, ~c"LitT", 0), - <<_header::binary-size(4), data::binary>> <- litt do - litu = :zlib.uncompress(data) - + litu <- maybe_uncompress_literals(litt) do chunks |> List.keyreplace(~c"LitT", 0, {~c"LitU", litu}) else @@ -27,6 +25,19 @@ defmodule ExAtomVM.PackBEAM do end end + defp maybe_uncompress_literals(chunk) do + case chunk do + <<0::32, data::binary>> -> + data + + <<_size::4-binary, data::binary>> -> + :zlib.uncompress(data) + + _ -> + nil + end + end + defp strip(chunks) do Enum.filter(chunks, fn {chunk_name, _} -> MapSet.member?(@allowed_chunks, chunk_name)