daemon: fixed memory leak and array bounds check fail

3 jobs for pull-42 in 2 minutes and 54 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #4378
docker linux amd64
build:linux:amd64

00:01:39

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

00:01:15

passed #4379
docker linux amd64
test:linux:amd64

00:00:51