qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] linux-user: Fix possible realloc memory leak


From: Stefan Weil
Subject: Re: [Qemu-devel] [PATCH] linux-user: Fix possible realloc memory leak
Date: Tue, 18 Jan 2011 18:59:22 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20101226 Iceowl/1.0b1 Icedove/3.0.11

Am 18.01.2011 18:51, schrieb Markus Armbruster:
Stefan Weil<address@hidden>  writes:

Am 18.01.2011 09:26, schrieb Markus Armbruster:
Stefan Weil<address@hidden>  writes:

Extract from "man realloc":
"If realloc() fails the original block is left untouched;
it is not freed or moved."

Fix a possible memory leak (reported by cppcheck).

Cc: Riku Voipio<address@hidden>
Signed-off-by: Stefan Weil<address@hidden>
Sidestep the problem via qemu_realloc() instead?
The same change was applied to bsd-user/elfload.c.

As symbol loading is not essential in most applications,
returning after out-of-memory should be better than
aborting (that's what qemu_realloc does).
Unless the requested size is *really* large, I'd expect this to stave
off the out-of-memory failure for a few microseconds at best.

If realloc fails, some memory is released before returning,
so maybe you would be surprised that your program
finishes without any more problems :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]