[util] Don't terminate string after a a 0 in -u
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 6 Nov 2018 15:49:19 +0000 (10:49 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 6 Nov 2018 15:49:19 +0000 (10:49 -0500)
Fixes https://github.com/harfbuzz/harfbuzz/issues/1361

util/options.cc
util/options.hh

index 5661cd0..3b22ca7 100644 (file)
@@ -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;
index 6d57d7d..0137484 100644 (file)
@@ -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;