The idea: every malloc has an owner
In C nobody frees memory for you. For every block you allocate, one piece of code is responsible for calling free exactly once. That piece of code is the owner.
A comment in a header often tells you who the owner is. Read it: "The CALLER owns the result."
The situation
make_greeting allocates a string and hands it out. log_greeting uses it, prints it, and returns. The test calls log_greeting a hundred times.
Your mission
Find the owner, then tell the junior which function must call free, on which variable, and where. "Fix the leak" is not an instruction. It is a wish.
What to watch for
- A vague request makes the junior reach for the nearest trick. Check what it did before you trust it.
- Freeing in the wrong function is worse than not freeing: it turns a leak into a crash.
- Some tests are hidden. They check the cases you did not think about.