#22 Missing include of alloca.h in nr-pathops.c

open
nobody
Bug Fix (11)
5
2004-04-05
2004-04-05
Robin KAY
No

alloca(3C) is defined in <alloca.h> on Solaris.

Discussion

  • Robin KAY

    Robin KAY - 2004-04-05

    Diff to nr-pathops.c

     
  • Tim Mooney

    Tim Mooney - 2004-04-07

    Logged In: YES
    user_id=36222

    Ditto for Tru64 UNIX, but I think the problem is even more
    widespread than just nr-pathops.c.

    For example, several of the files don't include stdlib.h,
    even though that's where the prototype for malloc() is.
    Without the prototype, a C89-conforming compiler will assume
    a return type of `int'. On an LP64 platform, that's going
    to cause problems, because the actual return type (void *)
    is larger than int. This can and does lead to crashes.

    What needs to happen is that configure.in needs to be
    modified to check for a few more header files (alloca.h, for
    one), and then all the files need to have a

    #ifdef HAVE_CONFIG_H
    # include <config.h>
    #endif

    #ifdef HAVE_ALLOCA_H
    # include <alloca.h>
    #endif

    #ifdef HAVE_WHATEVER_H
    # include <whatever.h>
    #endif

    ...

    and so on.

    I have a patch that does most of this already, but it still
    needs some work. I'm willing to put in that work if there's
    a chance the patch will be incorporated.

    Comments from the developers?

     
  • Tim Mooney

    Tim Mooney - 2004-04-10

    Logged In: YES
    user_id=36222

    For those that are interested, I think the patch I'm
    attaching catches all of the files at call malloc() or
    alloca(), and includes (conditionally) stdlib.h, malloc.h,
    and/or alloca.h, if the platform has them.

    It adds a bunch of header checks to configure.in, so you
    would need autoconf to be able to use this patch.

     

Log in to post a comment.