mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-09-17 23:11:30 +00:00
Stop leaking PedGeometry object memory (#767009)
Calling libparted ped_geometry_new() creates a new PedGeometry object from malloced memory, however the corresponding ped_geometry_destroy() is never called to destroy the object and free the memory. Perform a resize of a FAT file system when running GParted under valgrind identifies several memory blocks leaked via ped_geometry_new() from resize_move_filesystem_using_libparted(). One such example: # valgrind --track-origins=yes --leak-check=full ./gpartedbin ... ==32069== 32 bytes in 1 blocks are definitely lost in loss record 5,419 of 11,542 ==32069== at 0x4C29BFD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==32069== by 0x8ECD8C5: ped_malloc (libparted.c:231) ==32069== by 0x8ED23C1: ped_geometry_new (geom.c:79) ==32069== by 0x4764F3: GParted::GParted_Core::resize_move_filesystem_using_libparted(GParted::Partition const&, GParted::Partition const&, GParted::OperationDetail&) (GParted_Core.cc:2666) ==32069== by 0x478007: GParted::GParted_Core::resize_filesystem(GParted::Partition const&, GParted::Partition const&, GParted::OperationDetail&, bool) (GParted_Core.cc:2990) ==32069== by 0x478440: GParted::GParted_Core::maximize_filesystem(GParted::Partition const&, GParted::OperationDetail&) (GParted_Core.cc:3037) ==32069== by 0x4769A0: GParted::GParted_Core::resize(GParted::Partition const&, GParted::Partition const&, GParted::OperationDetail&) (GParted_Core.cc:2746) ==32069== by 0x47582B: GParted::GParted_Core::resize_move(GParted::Partition const&, GParted::Partition&, GParted::OperationDetail&) (GParted_Core.cc:2457) ==32069== by 0x46DDB2: GParted::GParted_Core::apply_operation_to_disk(GParted::Operation*) (GParted_Core.cc:767) ... There is also a leak of a PedGeometry object from resize_move_partition(). Fix by calling ped_geometry_destroy() to delete all the allocated PedGeometry objects and free the memory. Bug 767009 - PedGeometry objects are memory leaked
This commit is contained in:
parent
b7a0cc4724
commit
3724421e30
|
@ -2179,7 +2179,10 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail
|
||||||
new_partition .get_sector_length() ) ;
|
new_partition .get_sector_length() ) ;
|
||||||
|
|
||||||
if ( geom )
|
if ( geom )
|
||||||
|
{
|
||||||
constraint = ped_constraint_exact( geom ) ;
|
constraint = ped_constraint_exact( geom ) ;
|
||||||
|
ped_geometry_destroy( geom );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
constraint = ped_constraint_any( lp_device );
|
constraint = ped_constraint_any( lp_device );
|
||||||
|
@ -2673,9 +2676,12 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
|
||||||
if ( lp_geom )
|
if ( lp_geom )
|
||||||
{
|
{
|
||||||
fs = ped_file_system_open( lp_geom );
|
fs = ped_file_system_open( lp_geom );
|
||||||
|
|
||||||
|
ped_geometry_destroy( lp_geom );
|
||||||
|
lp_geom = NULL;
|
||||||
|
|
||||||
if ( fs )
|
if ( fs )
|
||||||
{
|
{
|
||||||
lp_geom = NULL ;
|
|
||||||
lp_geom = ped_geometry_new( lp_device,
|
lp_geom = ped_geometry_new( lp_device,
|
||||||
partition_new .sector_start,
|
partition_new .sector_start,
|
||||||
partition_new .get_sector_length() ) ;
|
partition_new .get_sector_length() ) ;
|
||||||
|
@ -2692,6 +2698,8 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
|
||||||
|
|
||||||
if ( return_value )
|
if ( return_value )
|
||||||
commit( lp_disk ) ;
|
commit( lp_disk ) ;
|
||||||
|
|
||||||
|
ped_geometry_destroy( lp_geom );
|
||||||
}
|
}
|
||||||
|
|
||||||
ped_file_system_close( fs );
|
ped_file_system_close( fs );
|
||||||
|
@ -2875,7 +2883,11 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
|
||||||
PedGeometry *geom = ped_geometry_new( lp_device,
|
PedGeometry *geom = ped_geometry_new( lp_device,
|
||||||
partition_new .sector_start,
|
partition_new .sector_start,
|
||||||
partition_new .get_sector_length() ) ;
|
partition_new .get_sector_length() ) ;
|
||||||
constraint = ped_constraint_exact( geom ) ;
|
if ( geom )
|
||||||
|
{
|
||||||
|
constraint = ped_constraint_exact( geom );
|
||||||
|
ped_geometry_destroy( geom );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
constraint = ped_constraint_any( lp_device ) ;
|
constraint = ped_constraint_any( lp_device ) ;
|
||||||
|
|
Loading…
Reference in a new issue