Add some range checking.

Change-Id: I907f185d82fb4f7273eb5341acd100815688c4f2
Fixes-issue: CLIENT-406
Reviewed-on: http://gerrit.dmdirc.com/2813
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>