[erlang-questions] memory leak in zlib:unzip

Justus mapandfold@REDACTED
Tue Mar 6 04:22:35 CET 2012

Hi all,

I think there are memory leaks in zlib:unzip, when it gets a wrong
stream. Test code is listed below.

check_erl() ->
    Bin = erlang:list_to_binary([X rem 256 || X <- lists:seq(0, 10000)]),
    check0(Bin, 0).

check0(Bin, Off) when Off > byte_size(Bin) -> 0;
check0(Bin, Off) ->
    <<_X:Off/binary, SB/binary>> = Bin,
    (catch zlib:unzip(SB)),
    check0(Bin, Off + 1).

Have a check on erlang:memory() before and after check_erl() is called.

Best Regards,

More information about the erlang-questions mailing list