Diff
Not logged in

Differences From Artifact [e1d0eb44d9]:

To Artifact [e11eca8c98]:


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
static int
Invalid(
    unsigned char *src)	/* Points to lead byte of a UTF-8 byte sequence */
{
    unsigned char byte = *src;
    int index;

    if (byte % 0x04) {
	/* Only lead bytes 0xC0, 0xE0, 0xF0, 0xF4 need examination */
	return 0;
    }
    index = (byte - 0xC0) >> 1;
    if (src[1] < bounds[index] || src[1] > bounds[index+1]) {
	/* Out of bounds - report invalid. */
	return 1;







|







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
static int
Invalid(
    unsigned char *src)	/* Points to lead byte of a UTF-8 byte sequence */
{
    unsigned char byte = *src;
    int index;

    if ((byte & 0xC3) != 0xC0) {
	/* Only lead bytes 0xC0, 0xE0, 0xF0, 0xF4 need examination */
	return 0;
    }
    index = (byte - 0xC0) >> 1;
    if (src[1] < bounds[index] || src[1] > bounds[index+1]) {
	/* Out of bounds - report invalid. */
	return 1;
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
	     * before the needs of the lead byte were satisfied.
	     * Let the (malformed) lead byte alone be a character
	     */
	    return src + 1;
	}
	next++;
    }
    if ((next == src + 1) || Invalid((unsigned char *)src)) {
	return src + 1;
    }
    return next;
}

/*
 *---------------------------------------------------------------------------







|







952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
	     * before the needs of the lead byte were satisfied.
	     * Let the (malformed) lead byte alone be a character
	     */
	    return src + 1;
	}
	next++;
    }
    if (Invalid((unsigned char *)src)) {
	return src + 1;
    }
    return next;
}

/*
 *---------------------------------------------------------------------------