PLK: potential memory leak

A PLK message describes heap memory that you have possibly leaked;  you cannot however be sure that the memory has been leaked because you have pointers only to the middle of the region.

In this example, 100 bytes are reported as potentially lost, not leaked. ptr does not point to the start of the block; it points 50 bytes into it. The free on line 10 assures that there is no leaked memory.

Memory in use can sometimes appear as a PLK if the pointer returned by malloc is offset. A common cause is referencing a substring within a large string. Another example is when a pointer to a C++ object is cast to the second or later base class of a multiply-inherited object. It is offset past the other base class objects.

Truly leaked memory can sometimes appear as a PLK, if some non-pointer integer within the program space, when interpreted as a pointer, points within an otherwise leaked block of memory. This is rather rare. Inspect the code to differentiate between these causes of PLK reports.