From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=50738 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfFqO-0006vL-Is for qemu-devel@nongnu.org; Tue, 18 Jan 2011 13:00:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfFq2-0005of-Ui for qemu-devel@nongnu.org; Tue, 18 Jan 2011 12:59:48 -0500 Received: from moutng.kundenserver.de ([212.227.17.8]:56561) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfFq2-0005nf-FK for qemu-devel@nongnu.org; Tue, 18 Jan 2011 12:59:26 -0500 Message-ID: <4D35D4FA.1080302@mail.berlios.de> Date: Tue, 18 Jan 2011 18:59:22 +0100 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] linux-user: Fix possible realloc memory leak References: <1295296566-30287-1-git-send-email-weil@mail.berlios.de> <4D35C960.6040703@mail.berlios.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Riku Voipio , QEMU Developers Am 18.01.2011 18:51, schrieb Markus Armbruster: > Stefan Weil writes: > > >> Am 18.01.2011 09:26, schrieb Markus Armbruster: >> >>> Stefan Weil 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 >>>> Signed-off-by: Stefan Weil >>>> >>> 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 :-)