From f918156b1099ed9e3e7461f0fc73ca6529443693 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Thu, 27 Oct 2011 22:24:57 -0400 Subject: [PATCH] Fix a bug with the calculation of the remaining length If the result of the string format was longer than the remaining length, the returned remaining length would be negative, which would make very strange things happen. --- src/lager_format.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lager_format.erl b/src/lager_format.erl index f1cf470..b3fa86e 100644 --- a/src/lager_format.erl +++ b/src/lager_format.erl @@ -145,7 +145,7 @@ build([], Acc, MaxLen, _O) -> build2([{C,As,F,Ad,P,Pad,Enc}|Cs], Count, MaxLen) -> {S, Len} = control2(C, As, F, Ad, P, Pad, Enc, MaxLen div Count), - [S|build2(Cs, Count - 1, MaxLen - Len)]; + [S|build2(Cs, Count - 1, MaxLen - abs(Len))]; build2([C|Cs], Count, MaxLen) -> [C|build2(Cs, Count, MaxLen)]; build2([], _, _) -> [].