public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: fix a segfault problem.
@ 2015-03-13  8:41 Wang Nan
  2015-03-13  9:46 ` Namhyung Kim
  0 siblings, 1 reply; 11+ messages in thread
From: Wang Nan @ 2015-03-13  8:41 UTC (permalink / raw)
  To: acme, namhyung, jolsa; +Cc: linux-kernel, mingo, lizefan, pi3orama

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'.

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-03-22 10:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-13  8:41 [PATCH] perf: fix a segfault problem Wang Nan
2015-03-13  9:46 ` Namhyung Kim
2015-03-13 10:07   ` Wang Nan
2015-03-13 11:20     ` Namhyung Kim
2015-03-13 12:51       ` [PATCH] perf: report: don't allow empty argument for '-t' Wang Nan
2015-03-16  2:20         ` Namhyung Kim
2015-03-19  6:41         ` Wang Nan
2015-03-19  7:26           ` Namhyung Kim
2015-03-19 14:00             ` Arnaldo Carvalho de Melo
2015-03-19 14:19               ` Namhyung Kim
2015-03-22 10:13         ` [tip:perf/core] perf report: Don't " tip-bot for Wang Nan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox