Skip to content

Fix V575 warning from PVS-Studio Static Analyzer#13

Open
buslov wants to merge 1 commit intopaxed:masterfrom
buslov:V547_fix
Open

Fix V575 warning from PVS-Studio Static Analyzer#13
buslov wants to merge 1 commit intopaxed:masterfrom
buslov:V547_fix

Conversation

@buslov
Copy link
Copy Markdown

@buslov buslov commented Oct 30, 2017

I'm a member of the Pinguem.ru competition on finding errors in open source projects. A bug, found using PVS-Studio.

Warning:
Expression 'p1' is always true.

Expression 'p1' is always true.
@herrwiese
Copy link
Copy Markdown

Your code is semantically equivalent, but it doesn't fix the actual problem. The check tries to determine whether the contents of p1 are to be used (it fails to do that, indeed), so a better approach would be to replace malloc(sz) with calloc(sz, 1) and replace the tests like if (p1) with if (*p1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants