From 7c0e3fa7789f413e8408e89ff7470e8ff86e7e72 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Sun, 24 Oct 2010 12:35:59 -0600 Subject: [PATCH] Fix crash moving more than one logical partition right (#628863) This problem would occur when using align to MiB for the destination partitions. Closes bug #628863 - gparted crashes applying move to right of more than one logical partition --- src/Dialog_Partition_Resize_Move.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index 43b3ec30..7987ef9e 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -101,8 +101,31 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector= (MEBIBYTE / selected_partition .sector_size) + ) + { + //Find maximum sector_end (allocated or unallocated) within list of + // partitions inside the extended partition + Sector max_sector_end = 0 ; + for (unsigned int k = 0 ; k < partitions .size() ; k++ ) + { + if ( partitions[ k ] .sector_end > max_sector_end ) + max_sector_end = partitions[ k ] .sector_end ; + } + + //If not within 1 MiB of the end of the extended partition, then reserve 1 MiB + if ( ( max_sector_end - partitions[t+1] .sector_end ) > ( MEBIBYTE / selected_partition .sector_size ) ) + next -= MEBIBYTE / selected_partition .sector_size ; + } + } + //Only calculate MIN_SPACE_BEFORE_MB if we have a previous (unallocated) partition. // Otherwise there will not be enough graphical space to reserve a full 1 MiB for MBR/EBR. // Since this is an existing partition, if an MBR/EBR was needed then it already exists with enough space.