Jakub Filak <[email protected]> writes:

> ---
>  src/plugins/rhbz.c |   21 ++++++++++-----------
>  1 files changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
> index a3aa2ef..2e7d62c 100644
> --- a/src/plugins/rhbz.c
> +++ b/src/plugins/rhbz.c
> @@ -88,20 +88,19 @@ static char *trim_all_whitespace(const char *str)
>  
>  int is_comment_dup(GList *comments, const char *comment)
>  {
> -    for (GList *l = comments; l; l = l->next)
> +    char * const trim_comment = trim_all_whitespace(comment);
> +    bool same_comments = false;
> +
> +    for (GList *l = comments; l && !same_comments; l = l->next)
>      {
> -        char *comment_body = (char *) l->data;
> -        char *trim_comment_body = trim_all_whitespace(comment_body);
> -        char *trim_comment = trim_all_whitespace(comment);
> -        if (!strcmp(trim_comment_body, trim_comment))
> -        {
> -            free(trim_comment_body);
> -            free(trim_comment);
> -            return 1;
> -        }
> +        const char * const comment_body = (const char *) l->data;
> +        char * const trim_comment_body = trim_all_whitespace(comment_body);
> +        same_comments = !strcmp(trim_comment_body, trim_comment);
> +        free(trim_comment_body);
>      }
>  
> -    return 0;;
> +    free(trim_comment);
> +    return same_comments;
>  }
>  
>  static unsigned find_best_bt_rating_in_comments(GList *comments)

pointless patch

we are leaking on many other places, but it's alright, beacuse it's not
long running process. Kernel always cleans all memory when process exits.

-- 
Nikola

Reply via email to