mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
UTF-8: Stepping functions set *count even if an assertion fails.
Previously, utf8_step_forward() and utf8_step_backward() left *count unchanged if some parameter was invalid. Now, they properly store 0. This flaw had no effect in practice, because all current callers pass count=NULL, and invalid parameters shouldn't be used anyway.
This commit is contained in:
parent
86c9cb01ba
commit
a01be8bd6b
@ -395,7 +395,7 @@ utf8_step_forward(unsigned char *string, unsigned char *end,
|
||||
|
||||
assert(string);
|
||||
assert(max >= 0);
|
||||
if_assert_failed return string;
|
||||
if_assert_failed goto invalid_arg;
|
||||
if (end == NULL)
|
||||
end = strchr(string, '\0');
|
||||
|
||||
@ -439,6 +439,7 @@ utf8_step_forward(unsigned char *string, unsigned char *end,
|
||||
INTERNAL("impossible enum utf8_step");
|
||||
}
|
||||
|
||||
invalid_arg:
|
||||
if (count)
|
||||
*count = steps;
|
||||
return current;
|
||||
@ -463,7 +464,7 @@ utf8_step_backward(unsigned char *string, unsigned char *start,
|
||||
assert(string);
|
||||
assert(start);
|
||||
assert(max >= 0);
|
||||
if_assert_failed return string;
|
||||
if_assert_failed goto invalid_arg;
|
||||
|
||||
switch (way) {
|
||||
case utf8_step_characters:
|
||||
@ -511,6 +512,7 @@ utf8_step_backward(unsigned char *string, unsigned char *start,
|
||||
INTERNAL("impossible enum utf8_step");
|
||||
}
|
||||
|
||||
invalid_arg:
|
||||
if (count)
|
||||
*count = steps;
|
||||
return current;
|
||||
|
Loading…
Reference in New Issue
Block a user