PG Bug reporting form <noreply@postgresql.org> writes: > The argument parsing duplicates strings, but never frees them.
This hardly amounts to enough of a problem to worry about. The string might be leaked, or it might not, but tracking whether it is is more trouble than it's worth. Generally we only worry about memory leaks if they (a) can waste a lot of memory or (b) can repeat, and thereby accumulate to waste a lot of memory. Surely neither one applies to postmaster argument parsing.
Your analysis is pretty educational! If the leak is small and has low impact, then the leak itself is not important; yet fixing the bug brings more complexity.
However, from the perspective of automated bug finding, I think removing the bug is beneficial. I'm trying to find bugs in PostgreSQL with sanitizers (the leak is reported by LeakSanitizer). If the bug cannot be fixed, LeakSanitizer stops at this shallow point, which prevents detecting more bugs in deep logic.
This is a great example of a case where the cure is likely to be worse than the disease. SelectConfigFiles surely has little business freeing its input string (indeed, it couldn't do so without casting away the "const"). On the other hand, the caller doesn't really know whether SelectConfigFiles is going to stash away a copy of the pointer; it wouldn't be unreasonable for it to do so. So in order to not perhaps-leak a few dozen bytes, we'd have to make that API more complicated and more fragile. It's not a win.
As for why we strdup the argument in the first place, see here: