eal/windows: add missing SPDX license tag
[dpdk.git] / lib / librte_eal / common / eal_common_trace_ctf.c
index 174cdac..33e419a 100644 (file)
@@ -37,11 +37,12 @@ meta_copy(char **meta, int *offset, char *str, int rc)
        if (rc < 0)
                return rc;
 
-       ptr = realloc(ptr, count + rc);
+       ptr = realloc(ptr, count + rc + 1);
        if (ptr == NULL)
                goto free_str;
 
        memcpy(RTE_PTR_ADD(ptr, count), str, rc);
+       ptr[count + rc] = '\0';
        count += rc;
        free(str);
 
@@ -231,9 +232,10 @@ meta_event_emit(char **meta, int *offset, struct trace_point *tp)
                "    id = %d;\n"
                "    name = \"%s\";\n"
                "    fields := struct {\n"
-               "        %s\n"
+               "%s"
                "    };\n"
-               "};\n\n", trace_id_get(tp->handle), tp->name, tp->ctf_field);
+               "};\n\n", trace_id_get(tp->handle), tp->name,
+               tp->ctf_field != NULL ? tp->ctf_field : "");
        return meta_copy(meta, offset, str, rc);
 }