summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wagner <bungeman@chromium.org>2020-12-10 14:12:05 -0500
committerBen Wagner <bungeman@chromium.org>2020-12-14 12:34:21 -0500
commit5cd11d19dfb2d901e1f6b690ae504d3bf5f5ff69 (patch)
tree46cca276f4dcc74c57c87960a3d61653be9c88b6
parentd55eaa6b3148691f32ec19c5c36dfc8818a6385f (diff)
Fix wild frees and leak of fs in test-conf.
Reported by AddressSanitizer when running test-conf. The `query`, `result`, and `result_fs` were not initialized to NULL so could result in a wild free when first initialized. The `method` was also not initialized to NULL so comparisons could be made against random data if it had not yet been assigned. The outer `fs` was never destroyed, but is also not used, so remove.
-rw-r--r--test/test-conf.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/test/test-conf.c b/test/test-conf.c
index d4de21a..6097983 100644
--- a/test/test-conf.c
+++ b/test/test-conf.c
@@ -158,7 +158,6 @@ static FcBool
run_test (FcConfig *config, json_object *root)
{
json_object *tests;
- FcFontSet *fs;
int i, n, fail = 0;
if (!json_object_object_get_ex (root, "tests", &tests) ||
@@ -167,15 +166,15 @@ run_test (FcConfig *config, json_object *root)
fprintf (stderr, "W: No test cases defined\n");
return FcFalse;
}
- fs = FcFontSetCreate ();
n = json_object_array_length (tests);
for (i = 0; i < n; i++)
{
json_object *obj = json_object_array_get_idx (tests, i);
json_object_iter iter;
- FcPattern *query, *result;
- FcFontSet *result_fs;
- const char *method;
+ FcPattern *query = NULL;
+ FcPattern *result = NULL;
+ FcFontSet *result_fs = NULL;
+ const char *method = NULL;
if (json_object_get_type (obj) != json_type_object)
continue;