Add explicit cast in xmlURIUnescapeString

Avoids an integer conversion warning with UBSan.
This commit is contained in:
Nick Wellnhofer 2022-01-25 01:39:41 +01:00
parent f872aa1807
commit 0596d67ddc

15
uri.c
View File

@ -1638,23 +1638,24 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
out = ret;
while(len > 0) {
if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
int c = 0;
in++;
if ((*in >= '0') && (*in <= '9'))
*out = (*in - '0');
c = (*in - '0');
else if ((*in >= 'a') && (*in <= 'f'))
*out = (*in - 'a') + 10;
c = (*in - 'a') + 10;
else if ((*in >= 'A') && (*in <= 'F'))
*out = (*in - 'A') + 10;
c = (*in - 'A') + 10;
in++;
if ((*in >= '0') && (*in <= '9'))
*out = *out * 16 + (*in - '0');
c = c * 16 + (*in - '0');
else if ((*in >= 'a') && (*in <= 'f'))
*out = *out * 16 + (*in - 'a') + 10;
c = c * 16 + (*in - 'a') + 10;
else if ((*in >= 'A') && (*in <= 'F'))
*out = *out * 16 + (*in - 'A') + 10;
c = c * 16 + (*in - 'A') + 10;
in++;
len -= 3;
out++;
*out++ = (char) c;
} else {
*out++ = *in++;
len--;