tests: fix leaks in internal-screenshot-test

Fixes all the ASan reported leaks in this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago committed by Pekka Paalanen
parent d3acfd3b6b
commit ca59c8e868
  1. 9
      tests/internal-screenshot-test.c

@ -91,7 +91,7 @@ TEST(internal_screenshot)
pixman_image_t *reference_bad = NULL;
pixman_image_t *diffimg;
struct rectangle clip;
const char *fname;
char *fname;
bool match = false;
bool dump_all_images = true;
@ -135,12 +135,14 @@ TEST(internal_screenshot)
testlog("Loading good reference image %s\n", fname);
reference_good = load_image_from_png(fname);
assert(reference_good);
free(fname);
/* Load bad reference image */
fname = screenshot_reference_filename("internal-screenshot-bad", 0);
testlog("Loading bad reference image %s\n", fname);
reference_bad = load_image_from_png(fname);
assert(reference_bad);
free(fname);
/* Test check_images_match() without a clip.
* We expect this to fail since we use a bad reference image
@ -166,6 +168,7 @@ TEST(internal_screenshot)
fname = screenshot_output_filename("internal-screenshot-error", 0);
write_image_as_png(diffimg, fname);
pixman_image_unref(diffimg);
free(fname);
}
pixman_image_unref(reference_good);
@ -173,10 +176,14 @@ TEST(internal_screenshot)
if (!match || dump_all_images) {
fname = screenshot_output_filename("internal-screenshot", 0);
write_image_as_png(screenshot->image, fname);
free(fname);
}
buffer_destroy(screenshot);
testlog("Test complete\n");
assert(match);
buffer_destroy(buf);
client_destroy(client);
}

Loading…
Cancel
Save