-1

I am running Coverity static analyzer tool on My Project which is having some flex/bison generated cpp file. Coverity is reporting following warning on one of the flex file.

CID 340350 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking **yyg->yy_buffer_stack**

suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

Code snippet of the flex generated file where Coverity reported issue :

if (YY_CURRENT_BUFFER) {
        DNParser_load_buffer_state(yyscanner );
        yyg->yy_did_buffer_switch_on_eof = 1;
    }
}
alessandrio
  • 4,282
  • 2
  • 29
  • 40
abhishekd
  • 133
  • 1
  • 5

1 Answers1

1

There are two possibilities - either it can be NULL in which case there's a bug as the pointer has already been dereferenced before it even got to the check, or the check is overly defensive coding that serves no point.

Since it's generated code, I'd be inclined to ignore the defect unless you believe that it actually can be NULL.

Caleb
  • 1,143
  • 5
  • 13