[apparmor] [patch 07/18] parser: pull forward free() calls [resend]

2014-01-16 Thread Steve Beattie
As noted by Seth Arnold, in expand_by_alternations() if our set
variable has at least one value, then we're going to rewrite the entry,
so rather than sprinkle the free()s near where the reallocation occurs,
use one free() once we're guaranteed to need to do so.

Signed-off-by: Steve Beattie 
---
 parser/parser_variable.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: b/parser/parser_variable.c
===
--- a/parser/parser_variable.c
+++ b/parser/parser_variable.c
@@ -177,10 +177,11 @@ static int expand_by_alternations(struct
exit(1);
}
 
+   free(*name);
+
value = get_next_set_value(valuelist);
if (!value) {
/* only one entry for the variable, so just sub it in */
-   free(*name);
if (asprintf(name, "%s%s%s",
 split_var->prefix ? split_var->prefix : "",
 first_value,
@@ -201,7 +202,6 @@ static int expand_by_alternations(struct
write_replacement(',', value, replacement, 
filter_leading_slash, filter_trailing_slash);
}
 
-   free(*name);
if (asprintf(name, "%s%s}%s",
 split_var->prefix ? split_var->prefix : "",
 replacement.c_str(),


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor


Re: [apparmor] [patch 07/18] parser: pull forward free() calls [resend]

2014-01-24 Thread John Johansen
On 01/16/2014 02:06 PM, Steve Beattie wrote:
> As noted by Seth Arnold, in expand_by_alternations() if our set
> variable has at least one value, then we're going to rewrite the entry,
> so rather than sprinkle the free()s near where the reallocation occurs,
> use one free() once we're guaranteed to need to do so.
> 
> Signed-off-by: Steve Beattie 

Acked-by: John Johansen 

> ---
>  parser/parser_variable.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Index: b/parser/parser_variable.c
> ===
> --- a/parser/parser_variable.c
> +++ b/parser/parser_variable.c
> @@ -177,10 +177,11 @@ static int expand_by_alternations(struct
>   exit(1);
>   }
>  
> + free(*name);
> +
>   value = get_next_set_value(valuelist);
>   if (!value) {
>   /* only one entry for the variable, so just sub it in */
> - free(*name);
>   if (asprintf(name, "%s%s%s",
>split_var->prefix ? split_var->prefix : "",
>first_value,
> @@ -201,7 +202,6 @@ static int expand_by_alternations(struct
>   write_replacement(',', value, replacement, 
> filter_leading_slash, filter_trailing_slash);
>   }
>  
> - free(*name);
>   if (asprintf(name, "%s%s}%s",
>split_var->prefix ? split_var->prefix : "",
>replacement.c_str(),
> 
> 
> -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or 
> unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
> 


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor