dgamelaunch icon indicating copy to clipboard operation
dgamelaunch copied to clipboard

Fix V575 warning from PVS-Studio Static Analyzer

Open buslov opened this issue 7 years ago • 1 comments

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.

buslov avatar Oct 30 '17 19:10 buslov

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).

herrwiese avatar Jul 03 '19 06:07 herrwiese