[util] Don't terminate string after a a 0 in -u

Fixes https://github.com/harfbuzz/harfbuzz/issues/1361
This commit is contained in:
Behdad Esfahbod 2018-11-06 10:49:19 -05:00
parent 8790b2740a
commit 3ec2e4fa7b
2 changed files with 5 additions and 1 deletions

View File

@ -325,6 +325,7 @@ parse_text (const char *name G_GNUC_UNUSED,
return false; return false;
} }
text_opts->text_len = -1;
text_opts->text = g_strdup (arg); text_opts->text = g_strdup (arg);
return true; return true;
} }
@ -370,6 +371,7 @@ parse_unicodes (const char *name G_GNUC_UNUSED,
s = p; s = p;
} }
text_opts->text_len = gs->len;
text_opts->text = g_string_free (gs, FALSE); text_opts->text = g_string_free (gs, FALSE);
return true; return true;
} }
@ -729,7 +731,7 @@ text_options_t::get_line (unsigned int *len)
if (text) { if (text) {
if (!line) line = text; if (!line) line = text;
if (line_len == (unsigned int) -1) if (line_len == (unsigned int) -1)
line_len = strlen (line); line_len = text_len;
if (!line_len) { if (!line_len) {
*len = 0; *len = 0;

View File

@ -506,6 +506,7 @@ struct text_options_t : option_group_t
text_before = nullptr; text_before = nullptr;
text_after = nullptr; text_after = nullptr;
text_len = -1;
text = nullptr; text = nullptr;
text_file = nullptr; text_file = nullptr;
@ -542,6 +543,7 @@ struct text_options_t : option_group_t
char *text_before; char *text_before;
char *text_after; char *text_after;
int text_len;
char *text; char *text;
char *text_file; char *text_file;