From patchwork Thu May 19 04:40:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9123931 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67C16BF29F for ; Thu, 19 May 2016 04:42:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD43220219 for ; Thu, 19 May 2016 04:42:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1845E201FA for ; Thu, 19 May 2016 04:42:14 +0000 (UTC) Received: from localhost ([::1]:48243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Fmn-0002dt-4N for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 May 2016 00:42:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3FmC-0002Yq-M3 for qemu-devel@nongnu.org; Thu, 19 May 2016 00:41:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3FmA-00056H-O8 for qemu-devel@nongnu.org; Thu, 19 May 2016 00:41:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Fly-00053C-3j; Thu, 19 May 2016 00:41:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4502A8AE; Thu, 19 May 2016 04:41:21 +0000 (UTC) Received: from red.redhat.com (ovpn-116-47.phx2.redhat.com [10.3.116.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4J4fFNF010616; Thu, 19 May 2016 00:41:21 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 18 May 2016 22:40:49 -0600 Message-Id: <1463632874-28559-4-git-send-email-eblake@redhat.com> In-Reply-To: <1463632874-28559-1-git-send-email-eblake@redhat.com> References: <1463632874-28559-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 19 May 2016 04:41:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 03/28] qemu-img: Don't leak errors when outputting JSON X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , armbru@redhat.com, "open list:Block layer core" , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If our JSON output ever encounters an error, we would just silently leak the local variable. Instead, assert that our usage won't fail. Signed-off-by: Eric Blake --- v4: new patch (split out from v3 14/18) --- qemu-img.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index b4f93ce..3aa7fb3 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -479,12 +479,11 @@ fail: static void dump_json_image_check(ImageCheck *check, bool quiet) { - Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; visit_type_ImageCheck(qmp_output_get_visitor(ov), NULL, &check, - &local_err); + &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL); @@ -2170,12 +2169,11 @@ static void dump_snapshots(BlockDriverState *bs) static void dump_json_image_info_list(ImageInfoList *list) { - Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list, - &local_err); + &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL); @@ -2187,11 +2185,11 @@ static void dump_json_image_info_list(ImageInfoList *list) static void dump_json_image_info(ImageInfo *info) { - Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; - visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info, &local_err); + visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info, + &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL);