cpu: verify that block->host is set

If it isn't, access at an offset will cause memory corruption.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amos Kong <akong@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
Michael S. Tsirkin 2014-11-12 11:44:47 +02:00 committed by Amit Shah
parent fd5f3b6367
commit b78accf614

View File

@ -316,6 +316,7 @@ typedef struct RAMBlock {
static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset)
{
assert(offset < block->length);
assert(block->host);
return (char *)block->host + offset;
}