Skip to content

Commit

Permalink
* regexec.c (slow_search): check the case when the length is 1.
Browse files Browse the repository at this point in the history
  The behavior of memcmp is undefined if the third argument is 0.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
mame committed May 19, 2008
1 parent 67d0fbd commit a4195fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon May 19 23:19:35 2008 Yusuke Endoh <mame@tsg.ne.jp>

* regexec.c (slow_search): check the case when the length is 1.
The behavior of memcmp is undefined if the third argument is 0.

Mon May 19 21:07:48 2008 Koichi Sasada <ko1@atdot.net>

* thread_pthread.c (native_thread_apply_priority):
Expand Down
4 changes: 2 additions & 2 deletions regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
if (*s == *target) {
p = s + 1;
t = target + 1;
if (memcmp(t, p, target_end - t) == 0)
if (target_end == t || memcmp(t, p, target_end - t) == 0)
return s;
}
s += n;
Expand All @@ -2776,7 +2776,7 @@ slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
if (*s == *target) {
p = s + 1;
t = target + 1;
if (memcmp(t, p, target_end - t) == 0)
if (target_end == t || memcmp(t, p, target_end - t) == 0)
return s;
}
s += enclen(enc, s, end);
Expand Down

0 comments on commit a4195fc

Please sign in to comment.