diff options
author | Stefan Weil <sw@weilnetz.de> | 2013-06-16 13:33:05 +0200 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2013-06-21 22:52:50 +0400 |
commit | 4f080057767a684aab60998659e18f98c5fbefc7 (patch) | |
tree | 99db044853120eae76fdceaaa5179e66e282769b /savevm.c | |
parent | 90527d2a8bb08ca5b4774eacfdd6b8fe9671c077 (diff) | |
download | qemu-4f080057767a684aab60998659e18f98c5fbefc7.zip qemu-4f080057767a684aab60998659e18f98c5fbefc7.tar.gz qemu-4f080057767a684aab60998659e18f98c5fbefc7.tar.bz2 |
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: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'savevm.c')
-rw-r--r-- | savevm.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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); |