check return of stream read and adapt vector size if necessary

Change-Id: I43d699b1e89ec327ec27566a98160a424216c78c