[PATCH] plug leaks in do_print

Jim Meyering meyering at redhat.com
Thu May 29 20:35:06 UTC 2008


* parted/parted.c (do_print):
25 bytes in 8 blocks are definitely lost...
   at 0x4A0739E: malloc (vg_replace_malloc.c:207)
   by 0x416E67: ped_malloc (libparted.c:234)
   by 0x41751F: ped_strdup (unit.c:179)
   by 0x417778: ped_unit_format_custom_byte (unit.c:220)
   by 0x417A90: ped_unit_format (unit.c:297)
   by 0x40CD85: do_print (parted.c:1517)
   by 0x40A035: command_run (command.c:139)
   by 0x41210C: non_interactive_mode (ui.c:1540)
   by 0x40EE41: main (parted.c:2482)

10 bytes in 4 blocks are definitely lost...
   at 0x4A0739E: malloc (vg_replace_malloc.c:207)
   by 0x416E9B: ped_malloc (libparted.c:234)
   by 0x417553: ped_strdup (unit.c:179)
   by 0x4177AC: ped_unit_format_custom_byte (unit.c:220)
   by 0x417AC4: ped_unit_format (unit.c:297)
   by 0x40CE34: do_print (parted.c:1527)
   by 0x40A035: command_run (command.c:139)
   by 0x412140: non_interactive_mode (ui.c:1540)
   by 0x40EE75: main (parted.c:2485)
---
 parted/parted.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index 4f04332..4af72ac 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1508,15 +1508,20 @@ do_print (PedDevice** dev)
                 else
                     fputs ("1:", stdout);

-                printf ("%s:", ped_unit_format (*dev, part->geom.start));
-                printf ("%s:", ped_unit_format_byte (
-                                *dev,
-                                (part->geom.end + 1) * 
-                                (*dev)->sector_size - 1));
-
-                if (ped_unit_get_default() != PED_UNIT_CHS)
-                    printf ("%s:", ped_unit_format (*dev,
-                                                    part->geom.length));
+                char *s = ped_unit_format (*dev, part->geom.start);
+                printf ("%s:", s);
+                free (s);
+                s = ped_unit_format_byte (*dev,
+                                          (part->geom.end + 1) *
+                                          (*dev)->sector_size - 1);
+                printf ("%s:", s);
+                free (s);
+
+                if (ped_unit_get_default() != PED_UNIT_CHS) {
+                    s = ped_unit_format (*dev, part->geom.length);
+                    printf ("%s:", s);
+                    free (s);
+                }
                     
                 if (!(part->type & PED_PARTITION_FREESPACE)) {

-- 
1.5.6.rc0.30.g7c3f3




More information about the parted-devel mailing list