gst-stats: Fix missing NULL checks

gst-inspect-1.0 segfaults on tracing logs where it fails to find
element stats. So on the pipelines where we get the following WARNING
during execution will afterwards crash with a segfault as the
g_ptr_array has a index for it but it is just a NULL pointer.

WARN default gst-stats.c:444:do_message_stats: no element stats found for ix=X

An example of an pipeline which can reproducibly create a trace log
where this occurs would be this

GST_DEBUG="GST_TRACER:7" GST_TRACERS="stats;rusage;latency" gst-launch-1.0 videotestsrc num-buffers=120 ! autovideosink &> trace.log
gst-stats-1.0 trace.log
29 jobs for master in 112 minutes and 21 seconds (queued for 1 minute and 33 seconds)
latest
Status Job ID Name Coverage
  Preparation
passed #869490
gst indent

00:00:58

passed #869489
manifest

00:00:44

 
  Build
passed #869500
build cerbero cross-android universal

00:10:21

manual #869504
gst-ios-12.2 allowed to fail manual
build cerbero cross-ios universal
passed #869501
build cerbero cross win32

00:09:13

passed #869502
build cerbero cross win64

00:05:09

passed #869499
build cerbero fedora x86_64

00:04:40

passed #869503
gst-macos-10.14
build cerbero macos x86_64

00:07:37

passed #869495
build clang fedora x86_64

00:10:59

passed #869491
build fedora x86_64

00:09:23

passed #869498
docker windows 1607
build msys2

00:14:52

passed #869492
build nodebug fedora x86_64

00:05:34

passed #869493
build static fedora x86_64

00:14:45

passed #869494
build static nodebug fedora x86_64

00:06:03

passed #869496
docker windows 1607
build vs2017 amd64

00:12:52

passed #869497
docker windows 1607
build vs2017 x86

00:10:53

 
  Test
passed #869505
check fedora

00:05:10

passed #869506
integration testsuites fedora

00:46:55

passed #869511
valgrind bad

00:10:37

passed #869508
valgrind base

00:14:26

passed #869722
valgrind core

00:10:59

passed #869512
valgrind ges

00:10:47

passed #869509
valgrind good

00:10:33

passed #869510
valgrind ugly

00:02:27

created #869721
valgrind core
failed #869507
valgrind core

00:19:45

 
  Integrate
passed #869513
cross-android universal examples

00:10:26

manual #869515
gst-ios-12.2 allowed to fail manual
cross-ios universal examples
passed #869514
documentation

00:02:51