[parted-devel] [PATCH] libparted: Use pri before freeing it.

Brian C. Lane bcl at redhat.com
Wed Feb 25 22:39:43 UTC 2015


This could have used pri after freeing it. Move it up into the if
clause.
---
 libparted/labels/gpt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 05847de..ffb9fa0 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -922,11 +922,13 @@ gpt_read_headers (PedDisk const *disk,
 
   bool valid_primary = _header_is_valid (disk, pri, 1);
   if (valid_primary)
-    *primary_gpt = pri;
+    {
+      *primary_gpt = pri;
+      gpt_disk_data->AlternateLBA = PED_LE64_TO_CPU (pri->AlternateLBA);
+    }
   else
     pth_free (pri);
 
-  gpt_disk_data->AlternateLBA = PED_LE64_TO_CPU (pri->AlternateLBA);
   if( !valid_primary || gpt_disk_data->AlternateLBA > dev->length - 1 )
     gpt_disk_data->AlternateLBA = dev->length - 1;
 
-- 
2.1.0




More information about the parted-devel mailing list