-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
erts: fix sub binary bug in erl_bif_re #9478
erts: fix sub binary bug in erl_bif_re #9478
Conversation
CT Test Results 4 files 227 suites 1h 55m 25s ⏱️ Results for commit 31849d0. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
@@ -629,6 +629,7 @@ static bool get_iolist_as_bytes(Eterm iolist, | |||
|
|||
ERTS_GET_BITSTRING(iolist, *bytes_p, bit_offs, bit_sz); | |||
if (!BIT_OFFSET(bit_offs) && !TAIL_BITS(bit_sz)) { | |||
*bytes_p += BYTE_OFFSET(bit_offs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
A testcase that tests regex as sub-binaries would be good. Maybe also test byte unaligned regex strings even if that is very unlikely to be used in practice.
Do we even have a testcase for subject strings as sub-binaries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, added tests
lib/stdlib/test/re_SUITE.erl
Outdated
try | ||
nomatch = re:run(Subject, Bin2, [{capture, none}]) | ||
catch error:badarg -> | ||
%% *** argument 2: neither an iodata term nor a compiled regular expression | ||
ok | ||
end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be something like
ok = try ... catch error:badarg -> ok end.
to make sure it actually raised a badarg.
lib/stdlib/test/re_SUITE.erl
Outdated
<<0:1, Subject2/binary>> = Bin2 = <<0:1,"::1">>, | ||
match = re:run(Subject2, REC, [{capture, none}]), | ||
match = re:run(Subject2, RE, [{capture, none}]), | ||
try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
bb104d9
to
31849d0
Compare
Closes GH-9438