Prevent read when offset past the end of the memstream
normal file semantics will return 0 for this indicating EOF
@@ -1495,7 +1495,7 @@ memstream_read (
memdata *md = static_cast<memdata *>( userdata );
uint64_t left = sz;
if ((offset + sz) > md->bytes)
- left = md->bytes - offset;
+ left = (offset < md->bytes) ? md->bytes - offset : 0;
if ( left > 0 )
memcpy( buffer, md->data + offset, left );
rdsz = static_cast<int64_t>( left );
