Hi,

I don't know if OpenBSD has a different implementation of alloca(3) than Linux. In Linux, alloca(3) (a.k.a. __builtin_alloca()) can't return NULL, as it can't detect errors. The only way to detect an error is to add a handler for SIGSEGV, AFAIK.

I found the following code in <lib/libc/gen/exec.c>:

        argv = alloca((n + 1) * sizeof(*argv));
        if (argv == NULL) {
                errno = ENOMEM;
                return (-1);
        }

But of course, that NULL should never happen, right?

As a side note, I think you could encapsulate the code calling alloca(3) into a helper macro, to avoid repetition.

I can prepare a patch if you confirm the bug.

Cheers,

Alex


--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

Reply via email to