lkml.org 
[lkml]   [2015]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] perf: fix a segfault problem.
On Fri, Mar 13, 2015 at 08:41:32AM +0000, Wang Nan wrote:
> Without this patch, perf report cause segfault if pass "" as '-t':
>
> $ perf report -t ""
>
> # To display the perf.data header info, please use --header/--header-only options.
> #
> # Samples: 37 of event 'syscalls:sys_enter_write'
> # Event count (approx.): 37
> #
> # Children SelfCommand Shared Object Symbol
> Segmentation fault
>
> This patch avoid the segfault by checking empty string for
> 'symbol_conf.field_sep'.

What about resetting it to NULL if empty string was given?

Thanks,
Namhyung


>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
> tools/perf/util/sort.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 4593f36..7f563a0 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -31,7 +31,8 @@ static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
>
> va_start(ap, fmt);
> n = vsnprintf(bf, size, fmt, ap);
> - if (symbol_conf.field_sep && n > 0) {
> + if (symbol_conf.field_sep && n > 0 &&
> + (symbol_conf.field_sep[0] != '\0')) {
> char *sep = bf;
>
> while (1) {
> --
> 1.8.3.4
>


\
 
 \ /
  Last update: 2015-03-13 11:01    [W:0.032 / U:4.996 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site