Erlang Mailing Lists

Author Message

<  Erlang patches mailing list  ~  [PATCH] Fix crash in string:copies/2

Guest
Posted: Fri Oct 29, 2010 7:07 am Reply with quote
Guest
Using a float for the number of copies results in an infinite loop.
Check the argument is an integer.

Reported-By: Eric Pailleau
---
lib/stdlib/src/string.erl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/stdlib/src/string.erl b/lib/stdlib/src/string.erl
index 6636a03..c987c22 100644
--- a/lib/stdlib/src/string.erl
+++ b/lib/stdlib/src/string.erl
@@ -201,7 +201,7 @@ chars(C, 0, Tail) when is_integer(C) ->

-spec copies(string(), non_neg_integer()) -> string().

-copies(CharList, Num) when is_list(CharList), Num >= 0 ->
+copies(CharList, Num) when is_list(CharList), is_integer(Num), Num >= 0 ->
copies(CharList, Num, []).

copies(_CharList, 0, R) ->
--
1.7.0.4


________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist
Guest
Posted: Fri Oct 29, 2010 7:27 am Reply with quote
Guest
On Sun, Oct 24, 2010 at 2:37 PM, Michael Santos
<michael.santos@gmail.com> wrote:
> Using a float for the number of copies results in an infinite loop.
> Check the argument is an integer.
>
> Reported-By: Eric Pailleau

Thanks! Will in include in pu.
--
Björn Gustavsson, Erlang/OTP, Ericsson AB

________________________________________________________________
erlang-patches (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-patches-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum