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

Brian C. Lane bcl at redhat.com
Fri Jul 31 15:57:31 UTC 2015


On Fri, Jul 31, 2015 at 12:12:44PM +0300, Amarnath Valluri wrote:
> * 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

This one looks good to me, thanks!

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)



More information about the parted-devel mailing list