This adds an integrity check at very little cost, and should stop Coverity from flagging array overruns on the result.