summaryrefslogtreecommitdiff
path: root/src/analysis/scan/exprs
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-11-01 21:36:50 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-11-01 21:36:50 (GMT)
commitce33112cf8c913635402cb8b6d127f9ac9f2b6b5 (patch)
tree731eaf0f50df1cc8033decbfce879b51ce5757e9 /src/analysis/scan/exprs
parent4eebf4a8752464691053fa3706ea6be9413676fa (diff)
Fix various memory leaks.
Diffstat (limited to 'src/analysis/scan/exprs')
-rw-r--r--src/analysis/scan/exprs/access.c2
-rw-r--r--src/analysis/scan/exprs/call.c4
-rw-r--r--src/analysis/scan/exprs/handler.c3
-rw-r--r--src/analysis/scan/exprs/literal.c21
4 files changed, 30 insertions, 0 deletions
diff --git a/src/analysis/scan/exprs/access.c b/src/analysis/scan/exprs/access.c
index a1331b0..342c2d7 100644
--- a/src/analysis/scan/exprs/access.c
+++ b/src/analysis/scan/exprs/access.c
@@ -391,6 +391,8 @@ GScanRegisteredItem *_g_scan_named_access_prepare_reduction(const GScanNamedAcce
g_scan_registered_item_resolve(base, expr->target, ctx, scope, &result);
+ g_object_unref(G_OBJECT(base));
+
}
/**
diff --git a/src/analysis/scan/exprs/call.c b/src/analysis/scan/exprs/call.c
index e335933..3997ff6 100644
--- a/src/analysis/scan/exprs/call.c
+++ b/src/analysis/scan/exprs/call.c
@@ -326,6 +326,10 @@ static ScanReductionState g_scan_pending_call_reduce(const GScanPendingCall *exp
{
if (new_args != NULL)
new_args[i] = new;
+
+ else
+ g_object_unref(G_OBJECT(new));
+
}
}
diff --git a/src/analysis/scan/exprs/handler.c b/src/analysis/scan/exprs/handler.c
index 8aab9e5..ea24443 100644
--- a/src/analysis/scan/exprs/handler.c
+++ b/src/analysis/scan/exprs/handler.c
@@ -168,6 +168,9 @@ static void g_scan_pattern_handler_dispose(GScanPatternHandler *handler)
static void g_scan_pattern_handler_finalize(GScanPatternHandler *handler)
{
+ if (handler->patterns != NULL)
+ free(handler->patterns);
+
G_OBJECT_CLASS(g_scan_pattern_handler_parent_class)->finalize(G_OBJECT(handler));
}
diff --git a/src/analysis/scan/exprs/literal.c b/src/analysis/scan/exprs/literal.c
index b1a094c..b7aed5b 100644
--- a/src/analysis/scan/exprs/literal.c
+++ b/src/analysis/scan/exprs/literal.c
@@ -124,6 +124,8 @@ static void g_scan_literal_expression_init(GScanLiteralExpression *expr)
{
G_SCAN_EXPRESSION(expr)->state = SRS_REDUCED;
+ memset(&expr->value, 0, sizeof(expr->value));
+
}
@@ -160,6 +162,25 @@ static void g_scan_literal_expression_dispose(GScanLiteralExpression *expr)
static void g_scan_literal_expression_finalize(GScanLiteralExpression *expr)
{
+ switch (expr->value_type)
+ {
+ case LVT_STRING:
+ exit_szstr(&expr->value.string);
+ break;
+
+ case LVT_REG_EXPR:
+ if (expr->value.regex != NULL)
+ {
+ free(expr->value.regex);
+ regfree(&expr->value.preg);
+ }
+ break;
+
+ default:
+ break;
+
+ }
+
G_OBJECT_CLASS(g_scan_literal_expression_parent_class)->finalize(G_OBJECT(expr));
}