aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2018-06-28 09:21:35 +0200
committerHans Bolinder <[email protected]>2018-06-28 09:21:35 +0200
commit8451f6e412bf8991c60d67805c5250d58ce702e1 (patch)
treeda351d5f7f6ce29cf9d6e4427d0fb4fc6008022a /lib/stdlib/src
parenta09907d56e29b24ded9a34de82bceac7f39021d1 (diff)
downloadotp-8451f6e412bf8991c60d67805c5250d58ce702e1.tar.gz
otp-8451f6e412bf8991c60d67805c5250d58ce702e1.tar.bz2
otp-8451f6e412bf8991c60d67805c5250d58ce702e1.zip
stdlib: Fix a 'chars_limit' bug
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/io_lib_pretty.erl12
1 files changed, 9 insertions, 3 deletions
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) ->