From nobody Tue Feb 10 20:14:30 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; dkim=fail; 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 1501123706834262.4398619781697; Wed, 26 Jul 2017 19:48:26 -0700 (PDT) Received: from localhost ([::1]:40880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYqf-000266-G4 for importer@patchew.org; Wed, 26 Jul 2017 22:48:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYlp-0005ry-7f for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:43:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daYlm-0008Dg-1z for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:43:25 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:35592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1daYll-0008Cr-TF; Wed, 26 Jul 2017 22:43:21 -0400 Received: by mail-qt0-x244.google.com with SMTP id t37so5778092qtg.2; Wed, 26 Jul 2017 19:43:21 -0700 (PDT) Received: from yoga.offpageads.com ([138.117.48.223]) by smtp.gmail.com with ESMTPSA id g27sm13221147qtg.84.2017.07.26.19.43.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 19:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZHNiRv57HAyRSdS1g+42AUFKWODTKfUiPQtl4GYrrwo=; b=nOeL33TMipAsqmJBdStbVJqyoOHSS0mvUygja7QVO5kfu8xiGhyqJLHVE6Fp8rjzJU piqR9q9TMojZCwFN92wu3TCGVO//wFKr5XoSYyHzKbAQvr+FNc3tzgMsN613KOK1PjA4 RF3QwIBngEB9r1SI2qDhsX8zbClsANyASydqYneXhph70b3fr8xO0Kn6NsfAi6z8P9If kONbbJcXDUJlF44BP4dFTaSwcn8I2mn9BYG2+TcL8g+WIOzVDFmLIoy6aasXAxj9Fbpi FSp4vx8F+sCUPx+72HhoVR9XmfsczlpFSSRCOVk9Csdx8bple1LiZUw96fKfn9pseP6z JoWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZHNiRv57HAyRSdS1g+42AUFKWODTKfUiPQtl4GYrrwo=; b=lX3A3MZ8+dTLzCkRA3/PzaSn+bnMck+NO//iFmMxFglb3HsJbBnba3pW392MgGZjXZ RRtV1MQC/VOog7QxIW04xN8f3Mf40B4A9cBXYnvHKqxs++bDBd39ZblZm3r0mpvVLyjq FFKj44iZc+mMHiARDx6SAVLgHnTxnmlQZ6WepFdKweLot4lk/AqaYoqHwknut+vRgSuw LmBK05KiuToK+BBu2BUA1PU2nN7reo1l+w32UKoxe6yf+mn/NCNXmuj/UWNdjXcnY4GH X/dH2yXKvdIFo+uZa1A+oCy6jJRiBlTzWSui5yk/tD2chiXL4wwg3hQFa2yTxJlDunDO VNGg== X-Gm-Message-State: AIVw113l/otKmNmNGTmDjFKAPXoGrbMscHtKR2RXhEGK5Il8khjgIEQE aMTRTxig/Folyg== X-Received: by 10.200.50.53 with SMTP id x50mr4039899qta.135.1501123401303; Wed, 26 Jul 2017 19:43:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eric Blake , Riku Voipio Date: Wed, 26 Jul 2017 23:42:20 -0300 Message-Id: <20170727024224.22900-16-f4bug@amsat.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170727024224.22900-1-f4bug@amsat.org> References: <20170727024224.22900-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH for 2.10 v2 15/20] 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, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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 --- 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.13.3