From 7c9c04485631119423e94cdb207c22c3cd633323 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 10 Sep 2014 16:20:04 -0400
Subject: [PATCH 13/31] Don't reuse a pointer to static data and free
conditionally.
Instead, use a second pointer and free that, because poor covscan can't
figure out what's going on.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/lib/unparse_path.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/lib/unparse_path.c b/src/lib/unparse_path.c
index 431dc06..5a69fde 100644
--- a/src/lib/unparse_path.c
+++ b/src/lib/unparse_path.c
@@ -325,6 +325,7 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size,
char text_uuid[40], *sig=text_uuid;
char a[16], b[16], c[16];
int rc = 0;
+ char *sig_allocated = NULL;
switch (hd->signature_type) {
case 0x00:
@@ -339,9 +340,11 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size,
return -1;
break;
case 0x02: /* GPT */
- rc = efi_guid_to_str((efi_guid_t *)hd->signature, &sig);
+ rc = efi_guid_to_str((efi_guid_t *)hd->signature,
+ &sig_allocated);
if (rc < 0)
return rc;
+ sig = sig_allocated;
break;
default:
return 0;
@@ -352,8 +355,8 @@ unparse_media_hard_drive_path(char *buffer, size_t buffer_size,
get(b, hd->start),
get(c, hd->size),
sig);
- if (hd->signature_type == 0x02)
- free(sig);
+ if (sig_allocated)
+ free(sig_allocated);
return rc;
}
--
2.7.4