From nobody Mon Feb 9 23:40:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501497238776489.06398696095755; Mon, 31 Jul 2017 03:33:58 -0700 (PDT) Received: from localhost ([::1]:58624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc81N-0004JF-3n for importer@patchew.org; Mon, 31 Jul 2017 06:33:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7zf-0003MZ-8G for qemu-devel@nongnu.org; Mon, 31 Jul 2017 06:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc7ze-0004Td-CG for qemu-devel@nongnu.org; Mon, 31 Jul 2017 06:32:11 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:38481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7ze-0004TJ-3s; Mon, 31 Jul 2017 06:32:10 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 5B55C42A9D; Mon, 31 Jul 2017 13:32:09 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 78690B8F; Mon, 31 Jul 2017 13:21:46 +0300 (MSK) Received: (nullmailer pid 5575 invoked by uid 1000); Mon, 31 Jul 2017 10:21:45 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 31 Jul 2017 13:21:37 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 18/25] thunk: assert nb_fields is valid 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: qemu-trivial@nongnu.org, Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 thunk.c:91:32: warning: Call to 'malloc' has an allocation size of 0 bytes se->field_offsets[i] =3D malloc(nb_fields * sizeof(int)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Michael Tokarev --- thunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thunk.c b/thunk.c index 2dac36666d..d5d8645cd4 100644 --- a/thunk.c +++ b/thunk.c @@ -67,7 +67,6 @@ void thunk_register_struct(int id, const char *name, cons= t argtype *types) int nb_fields, offset, max_align, align, size, i, j; =20 assert(id < max_struct_entries); - se =3D struct_entries + id; =20 /* first we count the number of fields */ type_ptr =3D types; @@ -76,6 +75,8 @@ void thunk_register_struct(int id, const char *name, cons= t argtype *types) type_ptr =3D thunk_type_next(type_ptr); nb_fields++; } + assert(nb_fields > 0); + se =3D struct_entries + id; se->field_types =3D types; se->nb_fields =3D nb_fields; se->name =3D name; --=20 2.11.0