CWE-762: Mismatched Memory Management Routines
Even though most programmers understand what is the difference between objects and pointers to them, sometimes it is not entirely clear, which of the ways of accessing the object to choose. We have tried to answer this question below.
The authors of the PVS-Studio analyzer invite you to test your attentiveness.
Code analyzers never get tired and can find errors a human’s eye cannot easily notice. We have picked a few code fragments with errors revealed by PVS-Studio, all the fragments taken from well-known open-source projects.
The C programming language was originally developed for and implemented on the UNIX operating system by Dennis Ritchie. C, a quite simple language, is not tied to any particular hardware or system. This makes it easy for a user to write programs that will run without any changes on practically all machines.