fix mem leak

This commit is contained in:
xiang.zhou
2024-11-27 14:16:12 +08:00
parent c0e16f41d4
commit d52ee1bbca
2 changed files with 6 additions and 1 deletions
+4
View File
@@ -29,6 +29,7 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <jansson.h>
@@ -246,6 +247,8 @@ static inline char *neu_value_str(neu_type_e type, neu_value_u value)
{
static __thread char str[128] = { 0 };
memset(str, 0, sizeof(str));
switch (type) {
case NEU_TYPE_INT8:
snprintf(str, sizeof(str), "type: %s, value: %i", neu_type_string(type),
@@ -314,6 +317,7 @@ static inline char *neu_value_str(neu_type_e type, neu_value_u value)
char *result = json_dumps(value.json, JSON_REAL_PRECISION(16));
snprintf(str, sizeof(str), "type: %s, value: %s", neu_type_string(type),
result);
free(result);
break;
}
default: