* [Qemu-devel] [PATCH] savevm: Fix potential memory leak
@ 2013-06-16 11:33 Stefan Weil
2013-07-02 20:33 ` Stefan Weil
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2013-06-16 11:33 UTC (permalink / raw)
To: qemu-trivial; +Cc: Stefan Weil, qemu-devel
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>
---
savevm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/savevm.c b/savevm.c
index 2ce439f..b883714 100644
--- a/savevm.c
+++ b/savevm.c
@@ -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);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] savevm: Fix potential memory leak
2013-06-16 11:33 [Qemu-devel] [PATCH] savevm: Fix potential memory leak Stefan Weil
@ 2013-07-02 20:33 ` Stefan Weil
2013-07-02 20:38 ` Stefan Weil
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2013-07-02 20:33 UTC (permalink / raw)
To: qemu-trivial; +Cc: qemu-devel
Am 16.06.2013 13:33, schrieb Stefan Weil:
> 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>
> ---
> savevm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/savevm.c b/savevm.c
> index 2ce439f..b883714 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -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);
Ping?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] savevm: Fix potential memory leak
2013-07-02 20:33 ` Stefan Weil
@ 2013-07-02 20:38 ` Stefan Weil
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Weil @ 2013-07-02 20:38 UTC (permalink / raw)
To: qemu-trivial; +Cc: qemu-devel
Am 02.07.2013 22:33, schrieb Stefan Weil:
> Am 16.06.2013 13:33, schrieb Stefan Weil:
>> 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>
>> ---
>> savevm.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/savevm.c b/savevm.c
>> index 2ce439f..b883714 100644
>> --- a/savevm.c
>> +++ b/savevm.c
>> @@ -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);
>
> Ping?
Sorry, that was bad bookkeeping on my side.
The patch was already applied.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-02 20:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-16 11:33 [Qemu-devel] [PATCH] savevm: Fix potential memory leak Stefan Weil
2013-07-02 20:33 ` Stefan Weil
2013-07-02 20:38 ` Stefan Weil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).