XPS: fix potential read overflow