From: Xie XiuQi <[email protected]>
Need to free "str" before return when asprintf() failed
to avoid memory leak.
Signed-off-by: Xie XiuQi <[email protected]>
---
tools/perf/util/sort.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index f14cc728c358..8ed777565c82 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2811,7 +2811,7 @@ static char *prefix_if_not_in(const char *pre, char *str)
return str;
if (asprintf(&n, "%s,%s", pre, str) < 0)
- return NULL;
+ n = NULL;
free(str);
return n;
--
2.17.1
Em Thu, May 21, 2020 at 09:32:17PM +0800, Wei Li escreveu:
> From: Xie XiuQi <[email protected]>
>
> Need to free "str" before return when asprintf() failed
> to avoid memory leak.
Thanks, applied.
- Arnaldo
> Signed-off-by: Xie XiuQi <[email protected]>
> ---
> tools/perf/util/sort.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index f14cc728c358..8ed777565c82 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -2811,7 +2811,7 @@ static char *prefix_if_not_in(const char *pre, char *str)
> return str;
>
> if (asprintf(&n, "%s,%s", pre, str) < 0)
> - return NULL;
> + n = NULL;
>
> free(str);
> return n;
> --
> 2.17.1
>
--
- Arnaldo