[Bug analyzer/108400] New: false positive: null dereference

chipitsine at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 13 18:46:11 GMT 2023


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

            Bug ID: 108400
           Summary: false positive: null dereference
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: chipitsine at gmail dot com
  Target Milestone: ---

bug is reproduced on the following gcc version:

commit f54e3b3ba01ced7ecda3caed51b42f707d489c77 (HEAD -> master, origin/trunk,
origin/master, origin/HEAD)
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Jan 12 00:29:33 2023 -0300


repro steps:

git clone --recursive https://github.com/SoftEtherVPN/SoftEtherVPN
cd SoftEtherVPN

export CC=/home/ilia/gcc/gcc-home/bin/gcc
export CFLAGS="-fanalyzer"

cmake .
make




I've reviewed the following finding, which I beleive is false positive

/home/ilia/SoftEtherVPN/src/Cedar/WebUI.c: In function ‘WuExpireSessionKey’:
/home/ilia/SoftEtherVPN/src/Cedar/WebUI.c:1871:29: warning: dereference of NULL
‘0’ [CWE-476] [-Wanalyzer-null-dereference]
 1871 |                 WU_CONTEXT *context = (WU_CONTEXT*)entry->Value;
      |                             ^~~~~~~
  ‘WuExpireSessionKey’: event 1
    |
    | 1868 |         for(i=0; i<LIST_NUM(wu->Contexts); i++)
    |
  ‘WuExpireSessionKey’: event 2
    |
    | 1870 |                 STRMAP_ENTRY *entry =
(STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i);
    |
  ‘WuExpireSessionKey’: event 3
    |
    | 1870 |                 STRMAP_ENTRY *entry =
(STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i);
    |
  ‘WuExpireSessionKey’: event 4
    |
    |/home/ilia/SoftEtherVPN/src/./Mayaqua/Memory.h:116:54:
    |  116 | #define LIST_DATA(o, i)         (((o) != NULL) ? ((o)->p[(i)]) :
NULL)
    |      |                                                   ~~~^~~
    |      |                                                      |
    |      |                                                      (4) ...to
here
/home/ilia/SoftEtherVPN/src/Cedar/WebUI.c:1870:54: note: in expansion of macro
‘LIST_DATA’
    | 1870 |                 STRMAP_ENTRY *entry =
(STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i);
    |      |                                                      ^~~~~~~~~
    |
  ‘WuExpireSessionKey’: event 5
    |
    | 1868 |         for(i=0; i<LIST_NUM(wu->Contexts); i++)
    |
  ‘WuExpireSessionKey’: events 6-7
    |
    | 1870 |                 STRMAP_ENTRY *entry =
(STRMAP_ENTRY*)LIST_DATA(wu->Contexts, i);
    | 1871 |                 WU_CONTEXT *context = (WU_CONTEXT*)entry->Value;
    |      |                             ~~~~~~~    
    |      |                             |
    |      |                             (7) dereference of NULL ‘<unknown>’
    |




WU_CONTEXT *context = (WU_CONTEXT*)entry->Value; - it is variable definition,
there's no dereference.


More information about the Gcc-bugs mailing list