Blame SOURCES/0012-Don-t-reuse-a-pointer-to-static-data-and-free-condit.patch

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