6666# endif
6767
6868# include <assert.h>
69+ # include <stddef.h>
6970
7071/*extern*/ const URI_CHAR * const URI_FUNC (SafeToPointTo ) = _UT ("X" );
7172/*extern*/ const URI_CHAR * const URI_FUNC (ConstPwd ) = _UT ("." );
@@ -106,6 +107,8 @@ int URI_FUNC(FreeUriPath)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
106107/* Compares two text ranges for equal text content */
107108int URI_FUNC (CompareRange )(const URI_TYPE (TextRange ) * a , const URI_TYPE (TextRange ) * b ) {
108109 int diff ;
110+ ptrdiff_t lenA ;
111+ ptrdiff_t lenB ;
109112
110113 /* NOTE: Both NULL means equal! */
111114 if ((a == NULL ) || (b == NULL )) {
@@ -117,14 +120,16 @@ int URI_FUNC(CompareRange)(const URI_TYPE(TextRange) * a, const URI_TYPE(TextRan
117120 return ((a -> first == NULL ) ? 0 : 1 ) - ((b -> first == NULL ) ? 0 : 1 );
118121 }
119122
120- diff = ((int )(a -> afterLast - a -> first ) - (int )(b -> afterLast - b -> first ));
121- if (diff > 0 ) {
123+ lenA = a -> afterLast - a -> first ;
124+ lenB = b -> afterLast - b -> first ;
125+
126+ if (lenA > lenB ) {
122127 return 1 ;
123- } else if (diff < 0 ) {
128+ } else if (lenA < lenB ) {
124129 return -1 ;
125130 }
126131
127- diff = URI_STRNCMP (a -> first , b -> first , (a -> afterLast - a -> first ) );
132+ diff = URI_STRNCMP (a -> first , b -> first , (size_t ) lenA );
128133
129134 if (diff > 0 ) {
130135 return 1 ;
@@ -727,7 +732,7 @@ UriBool URI_FUNC(FixPathNoScheme)(URI_TYPE(Uri) * uri, UriMemoryManager * memory
727732}
728733
729734/* When dropping a host from a URI without a scheme, an absolute path
730- * and and empty first path segment, a consecutive reparse would rightfully
735+ * and empty first path segment, a consecutive reparse would rightfully
731736 * mis-classify the first path segment as a host marker due to the "//".
732737 * To protect against this case, we prepend an artificial "." segment
733738 * to the path in here; the function is called after the host has
0 commit comments