From 8451f6e412bf8991c60d67805c5250d58ce702e1 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 28 Jun 2018 09:21:35 +0200 Subject: stdlib: Fix a 'chars_limit' bug --- lib/stdlib/src/io_lib_pretty.erl | 12 +++++++++--- lib/stdlib/test/io_SUITE.erl | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl index dca1b37ef3..ba9d9e8434 100644 --- a/lib/stdlib/src/io_lib_pretty.erl +++ b/lib/stdlib/src/io_lib_pretty.erl @@ -722,7 +722,7 @@ printable_list(L, _D, T, latin1) when T < 0 -> io_lib:printable_latin1_list(L); printable_list(L, _D, T, Enc) when T >= 0 -> case slice(L, tsub(T, 2)) of - {prefix, ""} -> + false -> false; {prefix, Prefix} when Enc =:= latin1 -> io_lib:printable_latin1_list(Prefix) andalso {true, Prefix}; @@ -738,11 +738,17 @@ printable_list(L, _D, T, _Uni) when T < 0-> io_lib:printable_list(L). slice(L, N) -> - case string:length(L) =< N of + try string:length(L) =< N of true -> all; false -> - {prefix, string:slice(L, 0, N)} + case string:slice(L, 0, N) of + "" -> + false; + Prefix -> + {prefix, Prefix} + end + catch _:_ -> false end. printable_bin0(Bin, D, T, Enc) -> diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index 91fe1133f6..79cee54335 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -31,7 +31,8 @@ otp_10836/1, io_lib_width_too_small/1, io_with_huge_message_queue/1, format_string/1, maps/1, coverage/1, otp_14178_unicode_atoms/1, otp_14175/1, - otp_14285/1, limit_term/1, otp_14983/1, otp_15103/1]). + otp_14285/1, limit_term/1, otp_14983/1, otp_15103/1, + otp_15159/1]). -export([pretty/2, trf/3]). @@ -63,7 +64,7 @@ all() -> io_lib_print_binary_depth_one, otp_10302, otp_10755, otp_10836, io_lib_width_too_small, io_with_huge_message_queue, format_string, maps, coverage, otp_14178_unicode_atoms, otp_14175, - otp_14285, limit_term, otp_14983, otp_15103]. + otp_14285, limit_term, otp_14983, otp_15103, otp_15159]. %% Error cases for output. error_1(Config) when is_list(Config) -> @@ -2633,3 +2634,8 @@ otp_15103(_Config) -> "[{a,\n b,\n c},\n {a,\n b,...},\n {a,...},\n {...}|...]" = lists:flatten(S5), ok. + +otp_15159(_Config) -> + "[atom]" = + lists:flatten(io_lib:format("~p", [[atom]], [{chars_limit,5}])), + ok. -- cgit v1.2.3 From 3a480fa8d1f50bf269a8f0227b9c640aa2058d10 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 29 Jun 2018 14:30:28 +0200 Subject: Update version numbers --- lib/stdlib/vsn.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/vsn.mk b/lib/stdlib/vsn.mk index 0525b2de0b..1d833430f1 100644 --- a/lib/stdlib/vsn.mk +++ b/lib/stdlib/vsn.mk @@ -1 +1 @@ -STDLIB_VSN = 3.5 +STDLIB_VSN = 3.5.1 -- cgit v1.2.3 From 5c8e7e905a678e1214cab55fed38d6d93fab04cb Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 29 Jun 2018 14:30:53 +0200 Subject: Update release notes --- lib/stdlib/doc/src/notes.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/stdlib') diff --git a/lib/stdlib/doc/src/notes.xml b/lib/stdlib/doc/src/notes.xml index 611bfe73e0..712a474b0b 100644 --- a/lib/stdlib/doc/src/notes.xml +++ b/lib/stdlib/doc/src/notes.xml @@ -31,6 +31,23 @@

This document describes the changes made to the STDLIB application.

+
STDLIB 3.5.1 + +
Fixed Bugs and Malfunctions + + +

Fix a bug that could cause a crash when formatting a + list of non-characters using the control sequences + p or P and limiting the output with the + option chars_limit.

+

+ Own Id: OTP-15159

+
+
+
+ +
+
STDLIB 3.5
Fixed Bugs and Malfunctions -- cgit v1.2.3