gemnasium/logrus-graylog-hook

Nil pointer dereference

Opened this issue · 2 comments

In case of unreachable graylog server GraylogHook.gelfLogger is silently initialized to nil: graylog_hook.go#L46 -> graylog_hook.go#L60
Then program crashes with nil pointer dereference on sending entry: graylog_hook.go#L146 -> graylog_hook.go#L208

I believe NewGraylogHook should return error and/or nil *GraylogHook or as a backward-compatible solution *GraylogHook should provide method to get initialization error.

Good catch!
I have turned this in my head several times: I don't think workaround solutions are better than returning the error in the initializer. As this is a breaking API change, we'll use gopkg.in to bump to 3.0 (that doesn't really make sense, but unless we have a real package manager in go, that's the way to go).

Thanks, I'll publish the new version in a few minutes.

1st step, fixing this for 2.x branch, so current user won't be affected.
Next step, 3.x branch with different api.