getline can allocate memory that cpputest doesn't know about
From the man page:
If *lineptr is set to NULL and *n is set 0 before the call, then getline() will allocate a buffer for storing the line. This buffer should be freed by the user program even if getline() failed.
Alternatively, before calling getline(), *lineptr can contain a pointer to a malloc(3)-allocated buffer *n bytes in size. If the buffer is not large enough to hold the line, getline() resizes it with realloc(3), updating *lineptr and *n as necessary.
So if you pass in either NULL or a buffer that is too small, cpputest will
foo:16: error:
Deallocating non-allocated memory
allocated at file: <unknown> line: 0 size: 0 type: unknown
The only idea I have for fixing this is making a cpputest_getline_location that checks if the size going in and going out are the same.
I think it could work, I'm just not sure if there are edge cases I'm not considering.
is this a similar issue to #289?
cpputest_getline_location is a good solution. You can make one locally and perhaps we can also include one in CppUTest. In the mean time, you can turn off the memory leak detection before feeing the buffer.
This would also work with string?
Do you mean. would this also work with std::string ? No, that seems to be a buffering issue and is usually best done by allocating a string outside of the memory leak detection scope (e.g. in main)