From 32a3ec7e47243ea2c2530445df83f60f992f0c23 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Mon, 6 Nov 2023 18:38:34 +0100 Subject: [PATCH] part: Fix potential double free when getting parttype fdisk_partition_get_type returns a pointer to a static table so we shouldn't free it. fdisk_unref_parttype should against this but we see some double free crashes that could be caused by this. Related: https://github.com/storaged-project/udisks/issues/1208 --- src/plugins/part.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/part.c b/src/plugins/part.c index 46d31137..20bb3628 100644 --- a/src/plugins/part.c +++ b/src/plugins/part.c @@ -462,7 +462,6 @@ static gchar* get_part_type_guid_and_gpt_flags (const gchar *device, int part_nu if (!ptype_string) { g_set_error (error, BD_PART_ERROR, BD_PART_ERROR_FAIL, "Failed to get partition type for partition %d on device '%s'", part_num, device); - fdisk_unref_parttype (ptype); fdisk_unref_partition (pa); close_context (cxt); return NULL; @@ -470,7 +469,6 @@ static gchar* get_part_type_guid_and_gpt_flags (const gchar *device, int part_nu ret = g_strdup (ptype_string); - fdisk_unref_parttype (ptype); fdisk_unref_partition (pa); close_context (cxt); return ret; -- 2.27.0