Dear gnulib developers, In the manual (safe-alloc.texi), I read for the definition of REALLOC_N:
If reallocation fails, the @code{ptr} variable is not modified. This claim is justified a little bit earlier in the text: Some of the memory allocation mistakes that are commonly made are @itemize @bullet … @item leaking memory in calls to @code{realloc} when that call fails. However, the definition in safe-alloc.h does not repeat this claim in the docstring. The macro definition is: #define REALLOC_N(ptr, count) \ safe_alloc_check ((ptr) = reallocarray (ptr, count, sizeof *(ptr))) I think it means that ptr is always replaced, and is set to NULL if the reallocation failed. Do I interpret this definition correctly? If yes, then it means that the old array leaks when realloc failed. Is this a bug, or did I misunderstand something in the safe-alloc module? Best regards, Vivien