avf: fix tx path segfault
[vpp.git] / src / vat / json_format.h
index 154fb3d..71db79e 100644 (file)
@@ -93,9 +93,8 @@ static_always_inline void
 vat_json_set_string_copy (vat_json_node_t * json, const u8 * str)
 {
   u8 *ns = NULL;
-  vec_validate (ns, strlen ((const char *) str));
-  strcpy ((char *) ns, (const char *) str);
-  vec_add1 (ns, '\0');
+  int len = strlen ((const char *) str);
+  vec_validate_init_c_string (ns, str, len);
   vat_json_set_string (json, ns);
 }