Comment 5 for bug 41804

Revision history for this message
Tomas Skäre (tomas-skare) wrote :

IMO, this is not an acceptable solution.

th_get_pathname() is part of the public API, and must not change behaviour
unless the major version of libtar is changed. This severely breaks compatibility
with existing programs, and affects portability a lot.

If a program uses libtar 1.2.11 on Solaris, th_get_pathname() returns a
strdup():ed pointer which must be free:d by the caller. If the same program
is compiled (also using libtar 1.2.11!) on Debian or Ubuntu, it must not free
the returned pointer. There is no way to know from the code if it must be
free:d or not.

If the original memory leak only happens for internal usage of th_get_pathname,
then another internal function should be added, and th_get_pathname can
use that function, but strdup() the return value.