This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12092] strstr broken for some inputs on pre-SSE4 machines


http://sourceware.org/bugzilla/show_bug.cgi?id=12092

--- Comment #5 from Eric Blake <eblake at redhat dot com> 2010-10-05 22:10:16 UTC ---
Your test for (memory > shift) will never be reached.  Other than the
assignment added by your proposed patch, memory is only ever assigned to be 0
or needle_len - period.  And for a periodic needle, shift is either needle_len
or < period, by virtue of how the shift table is constructed.  Therefore, if
memory is non-zero but shift >= period, then shift is necessarily > memory at
that point.

Which means your code can be reduced to this simpler patch:

diff --git i/string/str-two-way.h w/string/str-two-way.h
index 502af47..76044b3 100644
--- i/string/str-two-way.h
+++ w/string/str-two-way.h
@@ -350,8 +350,8 @@ two_way_long_needle (const unsigned char *haystack,
              a byte out of place, there can be no match until
              after the mismatch.  */
           shift = needle_len - period;
-          memory = 0;
         }
+          memory = 0;
           j += shift;
           continue;
         }

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]