diff --git a/include/neuron/type.h b/include/neuron/type.h index ec1bcfeb..826b966f 100644 --- a/include/neuron/type.h +++ b/include/neuron/type.h @@ -29,6 +29,7 @@ extern "C" { #include #include #include +#include #include @@ -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: diff --git a/src/adapter/driver/cache.c b/src/adapter/driver/cache.c index 31fd318d..cfe79ec4 100644 --- a/src/adapter/driver/cache.c +++ b/src/adapter/driver/cache.c @@ -668,7 +668,8 @@ void neu_driver_cache_update_change(neu_driver_cache_t *cache, elem->value.value.ptr.ptr = calloc(1, value.value.ptr.length); memcpy(elem->value.value.ptr.ptr, value.value.ptr.ptr, value.value.ptr.length); - } else if (value.type == NEU_TYPE_CUSTOM) { + } else if (value.type == NEU_TYPE_CUSTOM || + value.type == NEU_TYPE_ERROR) { if (elem->value.type == NEU_TYPE_CUSTOM && elem->value.value.json != NULL) { json_decref(elem->value.value.json);