+2015-06-25 Daiki Ueno <ueno@gnu.org>
+
+ * x-c.c (literalstring_parse): Bail out if C == NUL. Also adjust
+ the loop invariant in Unicode literal handling.
+ Reported by Hanno Boeck in:
+ <http://savannah.gnu.org/bugs/?45391>.
+
2015-06-25 Daiki Ueno <ueno@gnu.org>
* x-c.c (literalstring_parse): Add more NUL checks. Change the
case 'U': case 'u':
{
unsigned char buf[8];
- int length = c == 'u' ? 4 : 8;
+ int prefix = c;
+ int length = prefix == 'u' ? 4 : 8;
int n, j;
for (n = 0, j = 0; j < length; j++)
{
- int c1 = *p++;
-
- if (c1 >= '0' && c1 <= '9')
- n = (n << 4) + (c1 - '0');
- else if (c1 >= 'A' && c1 <= 'F')
- n = (n << 4) + (c1 - 'A' + 10);
- else if (c1 >= 'a' && c1 <= 'f')
- n = (n << 4) + (c1 - 'a' + 10);
+ c = *p++;
+
+ if (c >= '0' && c <= '9')
+ n = (n << 4) + (c - '0');
+ else if (c >= 'A' && c <= 'F')
+ n = (n << 4) + (c - 'A' + 10);
+ else if (c >= 'a' && c <= 'f')
+ n = (n << 4) + (c - 'a' + 10);
else
break;
- buf[j] = c1;
+ buf[j] = c;
}
if (j == length)
int i;
mixed_string_buffer_append_char (bp, '\\');
- mixed_string_buffer_append_char (bp, c);
+ mixed_string_buffer_append_char (bp, prefix);
for (i = 0; i < j; i++)
mixed_string_buffer_append_char (bp, buf[i]);
continue;
}
+ if (c == '\0')
+ break;
+
mixed_string_buffer_append_char (bp, c);
}