S2259 FP Null pointer dereference

I think this is a false positive, since getline() expects explicitly handles pointer to NULL and allocates for it.

See https://man7.org/linux/man-pages/man3/getline.3.html:

  getline() reads an entire line from stream, storing the address
  of the buffer containing the text into *lineptr.  The buffer is
  null-terminated and includes the newline character, if one was

  If *lineptr is set to NULL before the call, then getline() will
  allocate a buffer for storing the line.

If a private message is started, I can share a reproducer archive.

Thank you for the report @Inksz,

I was able to reproduce the issue and have created the following ticket CPP-3672, which you can use to track the issue. In the meantime, I would suggest marking the report as False Positive on SonarQube/SonarCloud page.

1 Like