buffered_file: g_realloc() can't fail
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
This commit is contained in:
parent
6f4d6b0908
commit
05e72dc581
@ -50,20 +50,12 @@ static void buffered_append(QEMUFileBuffered *s,
|
|||||||
const uint8_t *buf, size_t size)
|
const uint8_t *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (size > (s->buffer_capacity - s->buffer_size)) {
|
if (size > (s->buffer_capacity - s->buffer_size)) {
|
||||||
void *tmp;
|
|
||||||
|
|
||||||
DPRINTF("increasing buffer capacity from %zu by %zu\n",
|
DPRINTF("increasing buffer capacity from %zu by %zu\n",
|
||||||
s->buffer_capacity, size + 1024);
|
s->buffer_capacity, size + 1024);
|
||||||
|
|
||||||
s->buffer_capacity += size + 1024;
|
s->buffer_capacity += size + 1024;
|
||||||
|
|
||||||
tmp = g_realloc(s->buffer, s->buffer_capacity);
|
s->buffer = g_realloc(s->buffer, s->buffer_capacity);
|
||||||
if (tmp == NULL) {
|
|
||||||
fprintf(stderr, "qemu file buffer expansion failed\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->buffer = tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(s->buffer + s->buffer_size, buf, size);
|
memcpy(s->buffer + s->buffer_size, buf, size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user