From 1eaaad059941e0e2df008f5102ffc560d9ca3358 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Mon, 11 Nov 2019 19:29:12 +0000
Subject: [PATCH] _GLNX_TEST_SCOPED_TEMP_DIR: Fix memory and fd leak

This doesn't really matter, since it only happens when our process is
about to exit anyway, but it makes it easier to use AddressSanitizer
and similar tools.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 tests/libglnx-testlib.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/libglnx-testlib.c b/tests/libglnx-testlib.c
index 5687d8070..fd4fd653a 100644
--- a/tests/libglnx-testlib.c
+++ b/tests/libglnx-testlib.c
@@ -23,6 +23,8 @@
 
 #include <errno.h>
 
+#include <glib/gstdio.h>
+
 #include "libglnx.h"
 
 struct _GLnxTestAutoTempDir
@@ -63,4 +65,9 @@ _glnx_test_auto_temp_dir_leave (_GLnxTestAutoTempDir *dir)
 
   glnx_tmpdir_delete (&dir->temp_dir, NULL, &error);
   g_assert_no_error (error);
+
+  glnx_close_fd (&dir->old_cwd_fd);
+
+  g_free (dir->old_cwd);
+  g_free (dir);
 }
-- 
GitLab