NetBSD-Bugs archive

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

Re: lib/60054: libedit: adding user defined functions with narrow name/desription leaks memory



I originally looked at wcsdup()'ing then freeing each name/description in map_end.

However the builtin functions all have static strings so can't be freed.

So then I looked at just skipping the first EL_NUM_FCNS entries and freeing the rest.



Then I saw with el_wset(EL_ADDFN) there was no wcsdup() so I gathered the interface was supposed to use the passed in strings, as a library user could also just have static wstrings for their commands so no point in copying those. I looked at the man page but it wasn't clear whether EL_ADDFN was supposed to copy the strings or whether the caller had to guarantee the storage lifetime until el_end().



So then I settled on the list of buffers which are only used when narrow name/descriptions strings are passed.



But always copying strings whether narrow or wide would also work (perhaps skipping the first EL_NUM_FCNS builtin functions).

Freeing a const char* or const wchar_t* doesn't work though with the compiler warnings, you need an ugly double cast (i.e. free((void*)(intptr_t)ptr))


Home | Main Index | Thread Index | Old Index