cache: avoid some crashes

It's actually possible to start queries without any cache open,
e.g. add `resolve('.', kres.type.DNSKEY)` into your configuration.
If that happens, avoid the cache module dereferencing a NULL pointer.
26 jobs for <span class="ref-name">nitpicks</span> in 60 minutes and 51 seconds (queued for 5 seconds)
Status Job ID Name Coverage
  Build
passed #183158
docker linux amd64
build:clang:linux:amd64

00:00:44

passed #183157
docker linux amd64
build:linux:amd64

00:00:46

passed #183159
docker linux amd64 allowed to fail
srpm

00:00:25

 
  Test
passed #183166
docker linux amd64
deckard:linux:amd64

00:01:17

passed #183171
privileged
distro:epel-7

00:01:47

passed #183170
privileged
distro:fedora-29

00:02:29

passed #183165
docker
doc

00:00:47

passed #183164
docker linux amd64
installcheck:linux:amd64

00:01:02

passed #183167
docker linux amd64
installcheck:valgrind:linux:amd64

00:01:47

passed #183161
docker
lint:c

00:02:36

failed #183162
docker allowed to fail
lint:clang-scan-build

00:01:14

passed #183160
docker
lint:lua

00:00:38

passed #183169
docker linux amd64
respdiff:iter:udp:linux:amd64

00:02:43

passed #183163
docker linux amd64
test:linux:amd64

00:01:02

passed #183168
docker linux amd64
test:linux:amd64:valgrind

00:01:14

 
  Respdiff
failed #183172
respdiff
respdiff:fwd-tls6-kresd.udp6

00:28:13

passed #183173
respdiff
respdiff:fwd-udp6-kresd.udp6

00:35:42

failed #183214
respdiff
respdiff:fwd-udp6-unbound.tcp6

00:19:50

failed #183178
respdiff
respdiff:fwd-udp6-unbound.tls6

00:15:41

failed #183176
respdiff
respdiff:fwd-udp6-unbound.udp6

00:31:42

failed #183175
respdiff
respdiff:iter.tls6

00:49:15

failed #183174
respdiff
respdiff:iter.udp6

00:43:15

passed #183179
respdiff
resperf:fwd-tls6.udp-asan

00:16:05

passed #183180
respdiff
resperf:fwd-udp6.udp-asan

00:22:04

passed #183181
respdiff
resperf:iter.udp-asan

00:03:58

failed #183177
respdiff
respdiff:fwd-udp6-unbound.tcp6

00:17:41

 
Name Stage Failure
failed
respdiff:fwd-udp6-unbound.udp6 Respdiff
~/builds/ea0ef08e/7/knot/knot-resolver
Running after script...
$ cp -t . respdiff_commitdir/$RESPDIFF_TEST/j* ||:
$ cp -t . respdiff_commitdir/*$RESPDIFF_TEST*.png ||:
Uploading artifacts...
./j*: found 9 matching files
./*.png: found 3 matching files
Uploading artifacts to coordinator... ok id=183176 responseStatus=201 Created token=LDSA9r3P
ERROR: Job failed: exit status 1
failed
respdiff:iter.tls6 Respdiff
~/builds/ea0ef08e/3/knot/knot-resolver
Running after script...
$ cp -t . respdiff_commitdir/$RESPDIFF_TEST/j* ||:
$ cp -t . respdiff_commitdir/*$RESPDIFF_TEST*.png ||:
Uploading artifacts...
./j*: found 9 matching files
./*.png: found 3 matching files
Uploading artifacts to coordinator... ok id=183175 responseStatus=201 Created token=XZLxyLVg
ERROR: Job failed: exit status 1
failed
respdiff:fwd-udp6-unbound.tls6 Respdiff
~/builds/ea0ef08e/2/knot/knot-resolver
Running after script...
$ cp -t . respdiff_commitdir/$RESPDIFF_TEST/j* ||:
$ cp -t . respdiff_commitdir/*$RESPDIFF_TEST*.png ||:
Uploading artifacts...
./j*: found 9 matching files
./*.png: found 3 matching files
Uploading artifacts to coordinator... ok id=183178 responseStatus=201 Created token=TbUDk4zC
ERROR: Job failed: exit status 1
failed
respdiff:fwd-udp6-unbound.tcp6 Respdiff
~/builds/ea0ef08e/0/knot/knot-resolver
Running after script...
$ cp -t . respdiff_commitdir/$RESPDIFF_TEST/j* ||:
$ cp -t . respdiff_commitdir/*$RESPDIFF_TEST*.png ||:
Uploading artifacts...
./j*: found 9 matching files
./*.png: found 3 matching files
Uploading artifacts to coordinator... ok id=183214 responseStatus=201 Created token=ac6BXA5w
ERROR: Job failed: exit status 1
failed
respdiff:iter.udp6 Respdiff
~/builds/ea0ef08e/4/knot/knot-resolver
Running after script...
$ cp -t . respdiff_commitdir/$RESPDIFF_TEST/j* ||:
$ cp -t . respdiff_commitdir/*$RESPDIFF_TEST*.png ||:
Uploading artifacts...
./j*: found 9 matching files
./*.png: found 3 matching files
Uploading artifacts to coordinator... ok id=183174 responseStatus=201 Created token=5YWnSUrL
ERROR: Job failed: exit status 1
failed
respdiff:fwd-tls6-kresd.udp6 Respdiff
~/builds/ea0ef08e/6/knot/knot-resolver
Running after script...
$ cp -t . respdiff_commitdir/$RESPDIFF_TEST/j* ||:
$ cp -t . respdiff_commitdir/*$RESPDIFF_TEST*.png ||:
Uploading artifacts...
./j*: found 9 matching files
./*.png: found 3 matching files
Uploading artifacts to coordinator... ok id=183172 responseStatus=201 Created token=HUDeztyK
ERROR: Job failed: exit status 1
failed
lint:clang-scan-build Test
  CCLD	modules/hints/hints.so
CCLD modules/stats/stats.so
CCLD modules/bogus_log/bogus_log.so
scan-build: 31 bugs found.
scan-build: Run 'scan-view /builds/knot/knot-resolver/scan-results/2018-10-16-133735-16-1' to examine bug reports.
Uploading artifacts...
scan-results: found 36 matching files
Uploading artifacts to coordinator... ok id=183162 responseStatus=201 Created token=iNz_jbx1
ERROR: Job failed: exit code 1