dgamelaunch
dgamelaunch copied to clipboard
Fix V575 warning from PVS-Studio Static Analyzer
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.
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)
.