memstreams: fix incorrect handling of file pos > current size