summaryrefslogtreecommitdiff
path: root/src/maat_expr.c
diff options
context:
space:
mode:
authorroot <[email protected]>2024-10-14 02:25:36 +0000
committerroot <[email protected]>2024-10-14 02:25:36 +0000
commit78f733417cf8f11649101dc29aae79326eb553a6 (patch)
treea63c74a9a3ce957464a84a2407cb276e134e3d1a /src/maat_expr.c
parent586f1c11b20524066a3b4025cd4a59a14565ad32 (diff)
fix memory leak
Diffstat (limited to 'src/maat_expr.c')
-rw-r--r--src/maat_expr.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/maat_expr.c b/src/maat_expr.c
index ae21af4..45bab8a 100644
--- a/src/maat_expr.c
+++ b/src/maat_expr.c
@@ -104,35 +104,43 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
tmp_obj = cJSON_GetObjectItem(json, "object_uuid");
if (tmp_obj == NULL && tmp_obj->type != cJSON_String) {
+ char *json_str = cJSON_Print(json);
log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no object_id in line:%s",
- __FUNCTION__, __LINE__, table_name, cJSON_Print(json));
+ __FUNCTION__, __LINE__, table_name, json_str);
+ FREE(json_str);
goto error;
}
uuid_parse(tmp_obj->valuestring, expr_item->object_uuid);
tmp_obj = cJSON_GetObjectItem(json, "expression");
if (tmp_obj == NULL || tmp_obj->type != cJSON_String) {
+ char *json_str = cJSON_Print(json);
log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no expression in line:%s",
- __FUNCTION__, __LINE__, table_name, cJSON_Print(json));
+ __FUNCTION__, __LINE__, table_name, json_str);
+ FREE(json_str);
goto error;
}
len = strlen(tmp_obj->valuestring);
if (len > MAX_KEYWORDS_STR_LEN) {
+ char *json_str = cJSON_Print(json);
log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> expression length too long in line:%s",
- __FUNCTION__, __LINE__, table_name, cJSON_Print(json));
+ __FUNCTION__, __LINE__, table_name, json_str);
+ FREE(json_str);
goto error;
}
memcpy(expr_item->keywords, tmp_obj->valuestring, len);
tmp_obj = cJSON_GetObjectItem(json, "expr_type");
if (tmp_obj == NULL || tmp_obj->type != cJSON_String) {
+ char *json_str = cJSON_Print(json);
log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no expr_type in line:%s",
- __FUNCTION__, __LINE__, table_name, cJSON_Print(json));
+ __FUNCTION__, __LINE__, table_name, json_str);
+ FREE(json_str);
goto error;
}
@@ -145,9 +153,11 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
}
if (expr_item->expr_type == EXPR_TYPE_INVALID) {
+ char *json_str = cJSON_Print(json);
log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid expr_type in line:%s",
- __FUNCTION__, __LINE__, table_name, cJSON_Print(json));
+ __FUNCTION__, __LINE__, table_name, json_str);
+ FREE(json_str);
goto error;
} else if (expr_item->expr_type == EXPR_TYPE_REGEX) {
ret = expr_matcher_verify_regex_expression(expr_item->keywords, expr_rt->logger);
@@ -603,10 +613,12 @@ int expr_runtime_update(void *expr_runtime, void *expr_schema,
uuid_t item_uuid;
uuid_parse(tmp_obj->valuestring, item_uuid);
if (uuid_is_null(item_uuid)) {
+ char *json_str = cJSON_Print(json);
log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> item_id wrong"
" in table_line:%s", __FUNCTION__, __LINE__, table_name,
- cJSON_Print(json));
+ json_str);
+ FREE(json_str);
expr_rt->update_err_cnt++;
goto ERROR;
}