Commit 4f080057 authored by Stefan Weil's avatar Stefan Weil Committed by Michael Tokarev
Browse files

savevm: Fix potential memory leak



The leak was reported by cppcheck. Fix it by moving the g_malloc0 after
the argument validity check.
Signed-off-by: default avatarStefan Weil <sw@weilnetz.de>
Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
parent 90527d2a
......@@ -479,7 +479,7 @@ static const QEMUFileOps socket_write_ops = {
QEMUFile *qemu_fopen_socket(int fd, const char *mode)
{
QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
QEMUFileSocket *s;
if (mode == NULL ||
(mode[0] != 'r' && mode[0] != 'w') ||
......@@ -488,6 +488,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode)
return NULL;
}
s = g_malloc0(sizeof(QEMUFileSocket));
s->fd = fd;
if (mode[0] == 'w') {
qemu_set_block(s->fd);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment