From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6910D3858C33; Thu, 20 Apr 2023 13:36:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6910D3858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681997793; bh=JZzh9mLZ9NzjnXK8tGuUvp95+89rdY4JjzXjr83joOQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZU4Hf/4TD8v/79I0eglES/SWCU5u2796O1cWKzh4VGpjKw94Y3JsZuFqft8wIfml9 0H+tU7QqhkD17wIJZ39eV+q2c87TKZBuT1eE9fseUv4XldqdXXnG0rOUTlmlAU9rjo xtLau8QVJ7BQQDjeOOr4HCz8aFdrLpWqah7zgAjc= From: "vanyacpp at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/109570] detect fclose on unopened or NULL files Date: Thu, 20 Apr 2023 13:36:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vanyacpp at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109570 --- Comment #1 from Ivan Sorokin --- Generalizing. Perhaps similarly free(NULL) can be detected? void* obj =3D malloc(...); if (!obj) { free(obj); return false; } Unliky fclose(NULL), free(NULL) is completely well defined operation, but it does nothing and perhaps should be removed.=