File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -62,15 +62,16 @@ ci_is_less(
6262{
6363 auto p1 = s0.data ();
6464 auto p2 = s1.data ();
65- for (auto n = s0.size ();n--;)
65+ auto n = s0.size () < s1.size ()
66+ ? s0.size () : s1.size ();
67+ while (n--)
6668 {
6769 auto c1 = to_lower (*p1++);
6870 auto c2 = to_lower (*p2++);
6971 if (c1 != c2)
7072 return c1 < c2;
7173 }
72- // equal
73- return false ;
74+ return s0.size () < s1.size ();
7475}
7576
7677} // detail
Original file line number Diff line number Diff line change @@ -110,6 +110,12 @@ class ascii_test
110110 static_assert (std::is_same<
111111 decltype (ci_less{}(" a" , " b" )),
112112 bool >::value, " " );
113+
114+ // ci_is_less with mismatched lengths
115+ // (OOB read regression)
116+ BOOST_TEST (ci_is_less (" ab" , " abc" ));
117+ BOOST_TEST (! ci_is_less (" abc" , " ab" ));
118+ BOOST_TEST (! ci_is_less (" ABC" , " ab" ));
113119 }
114120
115121 void
You can’t perform that action at this time.
0 commit comments