Skip to content

Commit

Permalink
Fix a bug in the Erlang scanner
Browse files Browse the repository at this point in the history
The scanner did not crash when a floating point number was encountered
in the input string.
  • Loading branch information
uabboli committed Mar 28, 2013
1 parent a3054e2 commit b90269e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/stdlib/src/erl_scan.erl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ string_thing(_) -> "string".
-define(DIGIT(C), C >= $0, C =< $9).
-define(CHAR(C), is_integer(C), C >= 0).
-define(UNICODE(C),
is_integer(C) andalso
(C >= 0 andalso C < 16#D800 orelse
C > 16#DFFF andalso C < 16#FFFE orelse
C > 16#FFFF andalso C =< 16#10FFFF)).
Expand Down
13 changes: 11 additions & 2 deletions lib/stdlib/test/erl_scan_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).

-export([ error_1/1, error_2/1, iso88591/1, otp_7810/1, otp_10302/1]).
-export([ error_1/1, error_2/1, iso88591/1, otp_7810/1, otp_10302/1,
otp_10990/1]).

-import(lists, [nth/2,flatten/1]).
-import(io_lib, [print/1]).
Expand Down Expand Up @@ -60,7 +61,7 @@ end_per_testcase(_Case, Config) ->
suite() -> [{ct_hooks,[ts_install_cth]}].

all() ->
[{group, error}, iso88591, otp_7810, otp_10302].
[{group, error}, iso88591, otp_7810, otp_10302, otp_10990].

groups() ->
[{error, [], [error_1, error_2]}].
Expand Down Expand Up @@ -1121,6 +1122,14 @@ otp_10302(Config) when is_list(Config) ->
erl_parse:abstract("a"++[1024]++"c", [{encoding,latin1}]),
ok.

otp_10990(doc) ->
"OTP-10990. Floating point number in input string.";
otp_10990(suite) ->
[];
otp_10990(Config) when is_list(Config) ->
{'EXIT',_} = (catch {foo, erl_scan:string([$",42.0,$"],1)}),
ok.

test_string(String, Expected) ->
{ok, Expected, _End} = erl_scan:string(String),
test(String).
Expand Down

0 comments on commit b90269e

Please sign in to comment.