On 10/4/21 11:08 AM, Andreas Schwab wrote: > On Okt 04 2021, Chet Ramey wrote: > >> Nope, I don't buy that as the reason. xfree (name of function) and xfree(x) >> (macro defined in xmalloc.h) are not the same thing. > > That's exactly the problem. You cannot pass the return value from > sh_xmalloc to xfree, only sh_xfree.
That is absolutely not true with the bash malloc. It might be that valgrind makes certain assumptions about these functions, but those are not valid assumptions against the bash malloc implementation. You can freely mix calls to xmalloc/sh_xmalloc/malloc and xfree/sh_xfree/free. They all end up using the same set of internal functions and the same allocation pool. I've explained this previously, most recently in https://lists.gnu.org/archive/html/bug-bash/2017-04/msg00053.html >> and everything works correctly. > > Nope, it's undefined behaviour, as pointed out by valgrind. Nope. These are all functions internal to bash and the bash malloc, and they are all defined. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/