From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59398 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfFiI-0000JZ-By for qemu-devel@nongnu.org; Tue, 18 Jan 2011 12:51:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfFiG-0002xj-Co for qemu-devel@nongnu.org; Tue, 18 Jan 2011 12:51:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfFiG-0002xR-66 for qemu-devel@nongnu.org; Tue, 18 Jan 2011 12:51:24 -0500 From: Markus Armbruster 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> Date: Tue, 18 Jan 2011 18:51:00 +0100 In-Reply-To: <4D35C960.6040703@mail.berlios.de> (Stefan Weil's message of "Tue, 18 Jan 2011 18:09:52 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Riku Voipio , QEMU Developers 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.