Hi Jan,
I have 2 potential solutions to the apparent problem. Passing CPPUTEST_USE_MEM_LEAK_DETECTION=N to your makefile will disable the memory leak detection. Another solution is in the UT version makefile for the library also add:
CXXFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h
CFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h
But there are some smells of bad design, the problem you are with is exactly an example of why it's bad design.
Usually resource allocation & free should be symmetric, if you have a scandir library function allocating memory, you should have something like free_dir_array in the same library. And in the client code you always you them together.
br, Terry