summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2018-11-06 10:49:19 -0500
committerBehdad Esfahbod <behdad@behdad.org>2018-11-06 10:49:19 -0500
commit3ec2e4fa7bec07ec181a0390e5f5fd695abee611 (patch)
tree2e833c955b566b6b8cc06cfa30831a54bd563f66 /util
parent8790b2740a334f1789fb0cf329f2b8ac9733793c (diff)
[util] Don't terminate string after a a 0 in -u
Fixes https://github.com/harfbuzz/harfbuzz/issues/1361
Diffstat (limited to 'util')
-rw-r--r--util/options.cc4
-rw-r--r--util/options.hh2
2 files changed, 5 insertions, 1 deletions
diff --git a/util/options.cc b/util/options.cc
index 5661cd05..3b22ca72 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 6d57d7d6..0137484c 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;