Fix issues reported by LGTM (static code analyzer)

(from github.com/stweil)
LGTM reports several errors and warnings which should be fixed. It also reports some recommendations. See https://lgtm.com/projects/g/codelibs/fess/ for details.

(from github.com/marevol)
The bugs seems to be a false positive.