From d14e19b0636d8eb549acf54a6bdfb819d6be23fd Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Tue, 14 Jan 2003 02:07:16 +0000 Subject: [PATCH] Bug 188976: avoid calculating the difference of two unsigned integer if the difference is really a negative number. Thanks to Rick Swift for the patch. --- nsprpub/lib/libc/src/strstr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nsprpub/lib/libc/src/strstr.c b/nsprpub/lib/libc/src/strstr.c index 3f38a34fe99b..fe658c1b49d2 100644 --- a/nsprpub/lib/libc/src/strstr.c +++ b/nsprpub/lib/libc/src/strstr.c @@ -57,13 +57,15 @@ PL_strrstr(const char *big, const char *little) { const char *p; PRUint32 ll; + PRUint32 bl; if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; ll = PL_strlen(little); - p = &big[ PL_strlen(big) - ll ]; - if( p < big ) return (char *)0; + bl = PL_strlen(big); + if( bl < ll ) return (char *)0; + p = &big[ bl - ll ]; for( ; p >= big; p-- ) if( *little == *p )