]>
Commit | Line | Data |
---|---|---|
c886eb9d AM |
1 | From 059c9548534bef5b0312ac7089eb60e8596469be Mon Sep 17 00:00:00 2001 |
2 | From: Amarnath Valluri <amarnath.valluri@intel.com> | |
3 | Date: Fri, 31 Jul 2015 12:12:44 +0300 | |
4 | Subject: [PATCH 15/18] UI: Avoid memory leaks. | |
5 | ||
6 | * parted/ui.c(command_line_get_sector): Don't leak input string. | |
7 | * parted/ui.c(command_line_prompt_words): Don't leak _def string in | |
8 | opt script mode. | |
9 | ||
10 | Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com> | |
11 | Signed-off-by: Brian C. Lane <bcl@redhat.com> | |
12 | (cherry picked from commit 50dc0862a94a3e6e77d4cfb2af21de117fbb4819) | |
13 | --- | |
14 | parted/ui.c | 6 +++++- | |
15 | 1 file changed, 5 insertions(+), 1 deletion(-) | |
16 | ||
17 | diff --git a/parted/ui.c b/parted/ui.c | |
18 | index 7365e7d..505b8ac 100644 | |
19 | --- a/parted/ui.c | |
20 | +++ b/parted/ui.c | |
21 | @@ -829,8 +829,11 @@ command_line_prompt_words (const char* prompt, const char* def, | |
22 | } | |
23 | ||
24 | if (opt_script_mode) { | |
25 | - if (_def) | |
26 | + if (_def) { | |
27 | command_line_push_line (_def, 0); | |
28 | + if (_def_needs_free) | |
29 | + free (_def); | |
30 | + } | |
31 | return; | |
32 | } | |
33 | ||
34 | @@ -938,6 +941,7 @@ command_line_get_sector (const char* prompt, PedDevice* dev, PedSector* value, | |
35 | if (range) { | |
36 | *range = ped_geometry_new (dev, *value, 1); | |
37 | free (def_str); | |
38 | + free (input); | |
39 | return *range != NULL; | |
40 | } | |
41 | ||
42 | -- | |
43 | 2.4.3 | |
44 |