[parted-devel] [PATCH 1/2] UI: Avoid memory leaks.

Amarnath Valluri amarnath.valluri at intel.com
Fri Jul 31 09:12:44 UTC 2015


* parted/ui.c(command_line_get_sector): Don't leak input string.
* parted/ui.c(command_line_prompt_words): Don't leak _def string in
  opt script mode.

Signed-off-by: Amarnath Valluri <amarnath.valluri at intel.com>
---
 parted/ui.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/parted/ui.c b/parted/ui.c
index 7365e7d..505b8ac 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -829,8 +829,11 @@ command_line_prompt_words (const char* prompt, const char* def,
         }
 
         if (opt_script_mode) {
-                if (_def)
+                if (_def) {
                         command_line_push_line (_def, 0);
+                        if (_def_needs_free)
+                                free (_def);
+                }
                 return;
         }
 
@@ -938,6 +941,7 @@ command_line_get_sector (const char* prompt, PedDevice* dev, PedSector* value,
                 if (range) {
                         *range = ped_geometry_new (dev, *value, 1);
                         free (def_str);
+                        free (input);
                         return *range != NULL;
                 }
 
-- 
1.9.1

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the parted-devel mailing list