[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Autogrow configuration file token array (ITS#1786)

jwm@horde.net wrote:
> I'm just curious: why was the NULL-return checking on ch_realloc() added?
> I deliberately didn't check the return value because ch_realloc() checks
> for a failed BER allocation and asserts and exits if an allocation fails.
> AFAICT, the logging will never be called.

That's because the cn_realloc internal might change in the future, so it
is good practice to use a temporary and check the return value, to
control of the previously alloc'd memory (and dispose of it, in case).
Remember that *realloc in case of failure does not alter the previously
alloced memory.  cargv should be freed to clean up the heap, but since
in this specific case a memory failure while reading the configuration 
would likely result in an abort, I didn't take care of it.

Note that there was also an off by one bug when checking if cargv was


Dr. Pierangelo Masarati               | voice: +39 02 2399 8309
Dip. Ing. Aerospaziale                | fax:   +39 02 2399 8334
Politecnico di Milano                 |
via La Masa 34, 20156 Milano, Italy   |