Don't check null terminaion of source in hb_codepoint_parse
This isn't what intended originally, just checking if consumed all the buffer is enough.
This commit is contained in:
parent
3a16272750
commit
3661eb6105
|
@ -902,8 +902,8 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o
|
|||
const char *end = p + len;
|
||||
if (unlikely (!hb_parse_uint (&p, end, &v, base))) return false;
|
||||
|
||||
/* Pain because we don't know whether s is nul-terminated. */
|
||||
if (unlikely (p != end && *p)) return false;
|
||||
/* Check if parser consumed all of the buffer */
|
||||
if (unlikely (p != end)) return false;
|
||||
|
||||
*out = v;
|
||||
return true;
|
||||
|
|
|
@ -40,6 +40,7 @@ main (int argc, char **argv)
|
|||
assert (pv == 123);
|
||||
assert (pp - str == 3);
|
||||
assert (end - pp == 0);
|
||||
assert (!*end);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -52,6 +53,20 @@ main (int argc, char **argv)
|
|||
assert (pv == 123);
|
||||
assert (pp - str == 3);
|
||||
assert (end - pp == 0);
|
||||
assert (!*end);
|
||||
}
|
||||
|
||||
{
|
||||
const char str[] = "12F";
|
||||
const char *pp = str;
|
||||
const char *end = str + 3;
|
||||
|
||||
unsigned int pv;
|
||||
assert (hb_parse_uint (&pp, end, &pv, 16));
|
||||
assert (pv == 0x12F);
|
||||
assert (pp - str == 3);
|
||||
assert (end - pp == 0);
|
||||
assert (!*end);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -64,6 +79,7 @@ main (int argc, char **argv)
|
|||
assert (pv == -123);
|
||||
assert (pp - str == 4);
|
||||
assert (end - pp == 0);
|
||||
assert (!*end);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -77,6 +93,7 @@ main (int argc, char **argv)
|
|||
assert (pv == 123);
|
||||
assert (pp - str == 3);
|
||||
assert (end - pp == 1);
|
||||
assert (!*end);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -89,7 +106,20 @@ main (int argc, char **argv)
|
|||
assert (hb_parse_uint (&pp, end, &pv));
|
||||
assert (pv == 123);
|
||||
assert (pp - str == 3);
|
||||
assert (end - pp == 2); /* Similar to what hb_codepoint_parse needs */
|
||||
assert (end - pp == 2);
|
||||
}
|
||||
|
||||
{
|
||||
const char str[] = "123V";
|
||||
const char *pp = str;
|
||||
assert (ARRAY_LENGTH (str) == 5);
|
||||
const char *end = str + ARRAY_LENGTH (str);
|
||||
|
||||
unsigned int pv;
|
||||
assert (hb_parse_uint (&pp, end, &pv));
|
||||
assert (pv == 123);
|
||||
assert (pp - str == 3);
|
||||
assert (end - pp == 2);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue