summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian C. Lane <bcl@redhat.com>2021-06-10 15:41:33 -0700
committerBrian C. Lane <bcl@redhat.com>2021-06-11 13:47:36 -0700
commit8e6976661409d7c87b1f0a80ebdddc450b4db2dd (patch)
treed8f0c34d1465fa05d9d3c112ac7dd568ae1eaa4d
parentdacdfc20957d92eff7a3c9fd72baa849b45485e3 (diff)
downloadparted-8e6976661409d7c87b1f0a80ebdddc450b4db2dd.tar.gz
libparted: Fix potential memory leak in sdmmc_get_product_info
-rw-r--r--libparted/arch/linux.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 9dc90b5..aacc94f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1399,13 +1399,19 @@ static int
init_sdmmc (PedDevice* dev)
{
char id[128];
- char *type, *name;
+ char *type = NULL;
+ char *name = NULL;
if (sdmmc_get_product_info (dev, &type, &name)) {
snprintf (id, sizeof(id) - 1, "%s %s", type, name);
free (type);
free (name);
} else {
+ // One or the other may have been allocated, free it
+ if (type)
+ free(type);
+ if (name)
+ free(name);
snprintf (id, sizeof(id) - 1, "%s",
_("Generic SD/MMC Storage Card"));
}