fixed out-of-range vector and string accesses

Cherry-picked from openexr/openexr@73cd6efd29c73fd047f9cd5001f5ef05622323fd