From 3ec2e4fa7bec07ec181a0390e5f5fd695abee611 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 6 Nov 2018 10:49:19 -0500 Subject: [PATCH] [util] Don't terminate string after a a 0 in -u Fixes https://github.com/harfbuzz/harfbuzz/issues/1361 --- util/options.cc | 4 +++- util/options.hh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/util/options.cc b/util/options.cc index 5661cd0..3b22ca7 100644 --- a/util/options.cc +++ b/util/options.cc @@ -325,6 +325,7 @@ parse_text (const char *name G_GNUC_UNUSED, return false; } + text_opts->text_len = -1; text_opts->text = g_strdup (arg); return true; } @@ -370,6 +371,7 @@ parse_unicodes (const char *name G_GNUC_UNUSED, s = p; } + text_opts->text_len = gs->len; text_opts->text = g_string_free (gs, FALSE); return true; } @@ -729,7 +731,7 @@ text_options_t::get_line (unsigned int *len) if (text) { if (!line) line = text; if (line_len == (unsigned int) -1) - line_len = strlen (line); + line_len = text_len; if (!line_len) { *len = 0; diff --git a/util/options.hh b/util/options.hh index 6d57d7d..0137484 100644 --- a/util/options.hh +++ b/util/options.hh @@ -506,6 +506,7 @@ struct text_options_t : option_group_t text_before = nullptr; text_after = nullptr; + text_len = -1; text = nullptr; text_file = nullptr; @@ -542,6 +543,7 @@ struct text_options_t : option_group_t char *text_before; char *text_after; + int text_len; char *text; char *text_file; -- 2.7.4