From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwxe1-0006Ng-2s for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wwxdt-0002mg-KJ for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:58:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwxdt-0002mc-DF for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:57:57 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5HHvufP006966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 17 Jun 2014 13:57:56 -0400 From: Max Reitz Date: Tue, 17 Jun 2014 19:57:54 +0200 Message-Id: <1403027874-27274-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Silence covscan for g_realloc() result List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz g_realloc() returns NULL iff zero bytes are requested. Covscan therefore reports a possible NULL pointer dereference, however, this is not applicable here, as nb_clusters is guaranteed to be non-zero. In order to (hopefully) silence covscan, assert that the result of g_realloc() is truly non-NULL. Signed-off-by: Max Reitz --- See https://bugzilla.redhat.com/show_bug.cgi?id=1102409 for covscan's output. --- block/qcow2-refcount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 9507aef..4b81077 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1579,6 +1579,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, nb_clusters = (new_offset >> s->cluster_bits) + 1; refcount_table = g_realloc(refcount_table, nb_clusters * sizeof(uint16_t)); + assert(refcount_table); memset(&refcount_table[old_nb_clusters], 0, (nb_clusters - old_nb_clusters) * sizeof(uint16_t)); } -- 2.0.0