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

            Bug ID: 103685
           Summary: false positive error: dereference of NULL ‘params’
                    [CWE-476]
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: vt at altlinux dot org
  Target Milestone: ---

Obvious false positive:

gost_ec_sign.c: In function ‘fill_GOST_EC_params’:
gost_ec_sign.c:105:15: error: dereference of NULL ‘params’ [CWE-476]
[-Werror=analyzer-null-dereference]
  105 |     if (params->group) {
      |         ~~~~~~^~~~~~~
  ‘fill_GOST_EC_params’: events 1-3
    |
    |  100 |     if (!eckey || !params) {
    |      |        ^
    |      |        |
    |      |        (1) following ‘false’ branch...
    |......
    |  105 |     if (params->group) {
    |      |     ~~  ~~~~~~~~~~~~~
    |      |     |         |
    |      |     |         (3) dereference of NULL ‘params’
    |      |     (2) ...to here
    |


With the code like this:

  100     if (!eckey || !params) {
  101         GOSTerr(GOST_F_FILL_GOST_EC_PARAMS,
GOST_R_UNSUPPORTED_PARAMETER_SET);
  102         return 0;
  103     }
  104
  105     if (params->group) {

This is on compiling https://github.com/gost-engine/engine/

Back reference:
https://github.com/gost-engine/engine/issues/245#issuecomment-992007686

Reply via email to