Calculate offset correctly. (Coverity ID 233)