public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99615] New: gcc/cp/decl.c:10038:possible null pointer dereference
@ 2021-03-16 11:20 dcb314 at hotmail dot com
  2021-03-16 12:19 ` [Bug c++/99615] " marxin at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: dcb314 at hotmail dot com @ 2021-03-16 11:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99615

            Bug ID: 99615
           Summary: gcc/cp/decl.c:10038:possible null pointer dereference
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

cppcheck says

trunk.git/gcc/cp/decl.c:10038:7: warning: Either the condition 'attrlist' is
redundant or there is possible null pointer dereference: attrlist.
[nullPointerRedundantCheck]

Source code is

  decl = check_explicit_specialization (orig_declarator, decl,
                                        template_count,
                                        2 * funcdef_flag +
                                        4 * (friendp != 0) +
                                        8 * concept_p,
                                        *attrlist);
  if (decl == error_mark_node)
    return NULL_TREE;

  if (DECL_STATIC_FUNCTION_P (decl))
    check_static_quals (decl, quals);

  if (attrlist)
    {
      cplus_decl_attributes (&decl, *attrlist, 0);
      *attrlist = NULL_TREE;
    }

Note how the variable attrlist is used as a pointer, *before*
it is later checked.

Another possibility is that the final if statement should be

  if (*attrlist)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/99615] gcc/cp/decl.c:10038:possible null pointer dereference
  2021-03-16 11:20 [Bug c++/99615] New: gcc/cp/decl.c:10038:possible null pointer dereference dcb314 at hotmail dot com
@ 2021-03-16 12:19 ` marxin at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-03-16 12:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99615

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fjahanian at apple dot com,
                   |                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2021-03-16
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
It's very hairy code:

037cc9c5dce2 (Fariborz Jahanian         2004-09-23 18:22:25 +0000 10045)   if
(attrlist)
037cc9c5dce2 (Fariborz Jahanian         2004-09-23 18:22:25 +0000 10046)     {
037cc9c5dce2 (Fariborz Jahanian         2004-09-23 18:22:25 +0000 10047)      
cplus_decl_attributes (&decl, *attrlist, 0);
037cc9c5dce2 (Fariborz Jahanian         2004-09-23 18:22:25 +0000 10048)      
*attrlist = NULL_TREE;
037cc9c5dce2 (Fariborz Jahanian         2004-09-23 18:22:25 +0000 10049)     }
037cc9c5dce2 (Fariborz Jahanian         2004-09-23 18:22:25 +0000 10050) 


but yes, I think it should be 'if (*attrlist)'.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-16 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 11:20 [Bug c++/99615] New: gcc/cp/decl.c:10038:possible null pointer dereference dcb314 at hotmail dot com
2021-03-16 12:19 ` [Bug c++/99615] " marxin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).