vat: fix static analysis warning
[vpp.git] / src / vat / json_format.h
index 260c32e..71db79e 100644 (file)
@@ -94,8 +94,7 @@ vat_json_set_string_copy (vat_json_node_t * json, const u8 * str)
 {
   u8 *ns = NULL;
   int len = strlen ((const char *) str);
-  vec_validate (ns, len);
-  memcpy ((char *) ns, (const char *) str, len + 1);
+  vec_validate_init_c_string (ns, str, len);
   vat_json_set_string (json, ns);
 }