From 06a454a5b788066bee807f4be44a38b0cd6f8eab Mon Sep 17 00:00:00 2001 From: Alexander Mikhalitsyn Date: Wed, 26 Jun 2024 19:28:03 +0200 Subject: [PATCH] lxc/storage/zfs: ignore false-positive use-after-free warning free(dataset) is perfecly valid after failed realloc(dataset, len) call. Signed-off-by: Alexander Mikhalitsyn --- src/lxc/storage/zfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lxc/storage/zfs.c b/src/lxc/storage/zfs.c index 0047440447..521a9fd637 100644 --- a/src/lxc/storage/zfs.c +++ b/src/lxc/storage/zfs.c @@ -500,12 +500,20 @@ int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, */ dataset_len = strlen(dataset); len = 4 + dataset_len + 1 + strlen(cname) + 1; + +/* see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104069 */ +#pragma GCC diagnostic push +#if defined __GNUC__ && __GNUC__ >= 12 +#pragma GCC diagnostic ignored "-Wuse-after-free" +#endif new->src = realloc(dataset, len); if (!new->src) { ERROR("Failed to reallocate memory"); free(dataset); return -1; } +#pragma GCC diagnostic pop + memmove(new->src + 4, new->src, dataset_len); memmove(new->src, "zfs:", 4);