perf top: Fix segfault pressing -> with no hist entries
perf top: Fix segfault pressing -> with no hist entries

'perf top' segfaults with following operation:

 # perf top -e page-faults -p 11400 # 11400 never generates page-fault

Then on the resulting empty interface, press right key:

  # ./perf top -e page-faults -p 11400
  perf: Segmentation fault
  -------- backtrace --------
  ./perf[0x535428]
  /lib64/libc.so.6(+0x3545f)[0x7f0dd360745f]
  ./perf[0x531d46]
  ./perf(perf_evlist__tui_browse_hists+0x96)[0x5340d6]
  ./perf[0x44ba2f]
  /lib64/libpthread.so.0(+0x81d0)[0x7f0dd49dc1d0]
  /lib64/libc.so.6(clone+0x6c)[0x7f0dd36b90dc]

The bug resides in perf_evsel__hists_browse() that, in the above
circumstance browser->selection can be NULL, but code after
skip_annotation doesn't consider it.

This patch fix it by checking browser->selection before fetching
browser->selection->map.

Signed-off-by: Wang Nan <7b589a40e0ecd4816b422e8ed1f74a01c34bf6bb@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>
Cc: Namhyung Kim <5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org>
Cc: Zefan Li <a8167b9d27aca9c6624754deb52c4c6420eded04@huawei.com>
Cc: d3a709cba82ff13e91126748cd399b3cb8e95d2e@163.com
Link: http://lkml.kernel.org/r/1442226235-117265-1-git-send-email-7b589a40e0ecd4816b422e8ed1f74a01c34bf6bb@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs