Hi.
This code in regex_internal.c:
-------------------------------------
static reg_errcode_t
__attribute_warn_unused_result__
re_node_set_alloc (re_node_set *set, Idx size)
{
set->alloc = size;
set->nelem = 0;
set->elems = re_malloc (Idx, size);
if (__glibc_unlikely (set->elems == NULL))
return REG_ESPACE;
return REG_NOERROR;
}
-------------------------------------
If size is zero, malloc() is called with zero. IIRC, it's formally
undefined what happens if malloc(0) is called, and NULL is a possibly
valid result. If used with a malloc() that does return NULL, compilation
of a regex fails. regex needs to take this into account.
This happened in gawk using the Persistent Memory Allocator (PMA).
I have worked around it with additional gawk-specific code that sets
size to 1 if it's 0.
Thanks,
Arnold