From a10a7979887403ea61c30155cef18aa7324420a6 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 20 May 2014 22:01:19 +0200 Subject: Properly handle fields too short in io_lib_format Values for which the precision or field width were too small in io_lib_format could trigger an infinite loop or crash in term/5. Reported-by: Richard Carlsson --- lib/stdlib/src/io_lib_format.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/stdlib/src') diff --git a/lib/stdlib/src/io_lib_format.erl b/lib/stdlib/src/io_lib_format.erl index 56e15a17ec..89ae6fb187 100644 --- a/lib/stdlib/src/io_lib_format.erl +++ b/lib/stdlib/src/io_lib_format.erl @@ -255,7 +255,7 @@ term(T, none, _Adj, none, _Pad) -> T; term(T, none, Adj, P, Pad) -> term(T, P, Adj, P, Pad); term(T, F, Adj, P0, Pad) -> L = lists:flatlength(T), - P = case P0 of none -> erlang:min(L, F); _ -> P0 end, + P = erlang:min(L, case P0 of none -> F; _ -> min(P0, F) end), if L > P -> adjust(chars($*, P), chars(Pad, F-P), Adj); -- cgit v1.2.3