check sh.dataOffset bounds before using it as an offset in temporary buffer