From patchwork Tue Jan 15 13:23:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/4] w32: Make qemu_vfree() accept NULL like the POSIX implementation From: Markus Armbruster X-Patchwork-Id: 212156 Message-Id: <1358256220-5460-2-git-send-email-armbru@redhat.com> To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com Date: Tue, 15 Jan 2013 14:23:37 +0100 On POSIX, qemu_vfree() accepts NULL, because it's merely wrapper around free(). As far as I can tell, the Windows implementation doesn't. Breeds bugs that bite only under Windows. Make the Windows implementation behave like the POSIX implementation. Signed-off-by: Markus Armbruster --- util/oslib-win32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index e7e283e..640194c 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -71,7 +71,9 @@ void *qemu_vmalloc(size_t size) void qemu_vfree(void *ptr) { trace_qemu_vfree(ptr); - VirtualFree(ptr, 0, MEM_RELEASE); + if (ptr) { + VirtualFree(ptr, 0, MEM_RELEASE); + } } /* FIXME: add proper locking */