From 82e5b7dd568f4bfd8a77b809dd2c067e0a91e892 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 3 Aug 2021 16:38:34 -0400 Subject: [PATCH] xattrs: Fix possible double-free in `get_xattrs_impl` When we free `xattr_name`, we need to transfer ownership away to avoid potential for a double-free if we hit `ENOTSUP` on the next iteration. Reported-by: Seth Arnold --- glnx-xattrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glnx-xattrs.c b/glnx-xattrs.c index 892d5343..785ad0e4 100644 --- a/glnx-xattrs.c +++ b/glnx-xattrs.c @@ -181,7 +181,7 @@ get_xattrs_impl (const char *path, { if (errno == ERANGE) { - g_free (xattr_names); + g_free (g_steal_pointer (&xattr_names)); goto again; } glnx_set_prefix_error_from_errno (error, "%s", "llistxattr");