Re: [PATCH 12/23] parse-options: free previous value of `OPTION_FILENAME`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrick Steinhardt <ps@xxxxxx> writes:

> The `OPTION_FILENAME` option always assigns either an allocated string
> or `NULL` to the value. In case it is passed multiple times it does not
> know to free the previous value though, which causes a memory leak.

Our earlier attitude was "the user gave --filename twice from the
command line, fully knowing that the last one wins rule will make
the earlier one have no effect; not worth worrying about".

But defining the memory ownership rules and make sure the
library-ish part of the codebase honors these rules is absolutely
the right thing to do.

We saw earlier that OPT_PASSTHRU correctly frees the original value
before assigning the new value, and this makes OPT_FILENAME do the
same thing.  Nice.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux