From owner-freebsd-hackers@freebsd.org Thu Sep 15 09:53:18 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D45E8BDA8AA for ; Thu, 15 Sep 2016 09:53:18 +0000 (UTC) (envelope-from pipfstarrd@openmailbox.org) Received: from smtp12.openmailbox.org (smtp12.openmailbox.org [62.4.1.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B5691445 for ; Thu, 15 Sep 2016 09:53:17 +0000 (UTC) (envelope-from pipfstarrd@openmailbox.org) Received: by mail2.openmailbox.org (Postfix, from userid 1001) id 998D71028B0; Thu, 15 Sep 2016 11:53:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1473933189; bh=SrLmq5V6IBeXgLO663rqduS8Ga3pK/LS6c1dCL/jt5s=; h=To:From:Subject:Date:From; b=cEmt6rPbHP2POQJIpY8oPSfAuEJkAKD7uKY2/q6urTxmRuGqilox8LC2TH3owNbZy hZVirDcyWC6+/FbaoOcR4+cxP3OzOTIl0WWcVy81R+PUPe704h0JbZpKOWXphmzq67 ys7zSGXIiNFzX4ToVuYVADh8a8Ymy4r233k5F5Lw= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on h3 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_RECEIVED, NO_RELAYS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 To: freebsd-hackers@FreeBSD.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1473933189; bh=SrLmq5V6IBeXgLO663rqduS8Ga3pK/LS6c1dCL/jt5s=; h=To:From:Subject:Date:From; b=cEmt6rPbHP2POQJIpY8oPSfAuEJkAKD7uKY2/q6urTxmRuGqilox8LC2TH3owNbZy hZVirDcyWC6+/FbaoOcR4+cxP3OzOTIl0WWcVy81R+PUPe704h0JbZpKOWXphmzq67 ys7zSGXIiNFzX4ToVuYVADh8a8Ymy4r233k5F5Lw= From: Daniil Berendeev Subject: Multiple possible null-pointer dereferences Message-ID: <614a3aa7-a903-23f5-33b8-c367f22cd454@openmailbox.org> Date: Thu, 15 Sep 2016 09:53:30 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2016 09:53:18 -0000 Hello, its cppcheck guy again. I'm digging through error messages, and there are lots of them related to null pointer dereferences. But I'm not sure if those should be considered as bugs and fixed. Maybe I'm missing a point? Here are some common examples of how it looks like: 1) First snippet: static int dbd_freetds_end_transaction(apr_dbd_transaction_t *trans) { int dummy; if (trans) { // <-- Here we check whether trans is a valid pointer // skipped irrelevant code } // But here we dereference is without a fuss. return (trans->handle->err == SUCCEED) ? 0 : 1; } 2) Second snippet: static int dbd_oracle_end_transaction(apr_dbd_transaction_t *trans) { int ret = 1; /* no transaction is an error cond */ sword status; // *** We dereference the pointer *** apr_dbd_t *handle = trans->handle; if (trans) { // <-- and check if it is valid after that, lol //... 3) Third snippet // *** Again, here we dereference the pointer *** assert(stab->n_type != N_FUN || (iidescp->ii_type != II_GFUN && iidescp->ii_type != II_SFUN) || scope == 0); //... if (scope && stab->n_type != N_PSYM) { if (iidescp) // <-- and here check if it's valid iidesc_free(iidescp, NULL); And there are tons (973 to be precise) of examples like these above. Should those be considered as bugs and be fixed, or they are fine? -- Cheers~ PGP key fingerprint: 07B3 2177 3E27 BF41 DC65 CC95 BDA8 88F1 E9F9 CEEF You can retrieve my public key at pgp.mit.edu. -- Cheers~ PGP key fingerprint: 07B3 2177 3E27 BF41 DC65 CC95 BDA8 88F1 E9F9 CEEF You can retrieve my public key at pgp.mit.edu.