Blob Blame History Raw
From 059c9548534bef5b0312ac7089eb60e8596469be Mon Sep 17 00:00:00 2001
From: Amarnath Valluri <amarnath.valluri@intel.com>
Date: Fri, 31 Jul 2015 12:12:44 +0300
Subject: [PATCH 15/18] UI: Avoid memory leaks.

* 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@intel.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
(cherry picked from commit 50dc0862a94a3e6e77d4cfb2af21de117fbb4819)
---
 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;
                 }
 
-- 
2.4.3