From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAoTH-0001ue-9a for qemu-devel@nongnu.org; Thu, 22 Mar 2012 16:18:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAoTF-0000yK-7C for qemu-devel@nongnu.org; Thu, 22 Mar 2012 16:18:54 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:38921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAoTF-0000y8-19 for qemu-devel@nongnu.org; Thu, 22 Mar 2012 16:18:53 -0400 Received: by pbcuo5 with SMTP id uo5so2215880pbc.4 for ; Thu, 22 Mar 2012 13:18:51 -0700 (PDT) Message-ID: <4F6B8928.3030400@codemonkey.ws> Date: Thu, 22 Mar 2012 15:18:48 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1332417072-20329-1-git-send-email-pbonzini@redhat.com> <1332417072-20329-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1332417072-20329-6-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/10] qapi: allow freeing partially-allocated objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: lcapitulino@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com On 03/22/2012 06:51 AM, Paolo Bonzini wrote: > Objects going through the dealloc visitor can be only partially allocated. > Detect the situation and avoid a segfault. This also helps with the > input visitor, when there are errors. > > Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori Regards, Anthony Liguori > --- > scripts/qapi-visit.py | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py > index b242315..a85fb76 100644 > --- a/scripts/qapi-visit.py > +++ b/scripts/qapi-visit.py > @@ -65,6 +65,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** > return; > } > visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), errp); > + if (obj&& !*obj) { > + goto end; > + } > ''', > name=name) > push_indent() > @@ -72,6 +75,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** > pop_indent() > > ret += mcgen(''' > +end: > visit_end_struct(m, errp); > } > ''') > @@ -122,6 +126,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** > return; > } > visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s),&err); > + if (obj&& !*obj) { > + goto end; > + } > visit_type_%(name)sKind(m,&(*obj)->kind, "type",&err); > if (err) { > error_propagate(errp, err);