bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

posix_memalign requires incorrect constraints on its arguments


From: Steven G. Johnson
Subject: posix_memalign requires incorrect constraints on its arguments
Date: Fri, 13 Sep 2002 22:36:14 -0400 (EDT)

According to:

http://www.opengroup.org/onlinepubs/007904975/functions/posix_memalign.html

as well as glibc's own documentation, the posix_memalign(&buf,size,align)
function requires its ALIGN argument to be a power-of-two multiple of
sizeof(void*).

However, looking in the glibc-2.2.5 source (malloc/malloc.c),
posix_memalign actually does:

  /* Test whether the SIZE argument is valid.  It must be a power of
     two multiple of sizeof (void *).  */
  if (size % sizeof (void *) != 0 || (size & (size - 1)) != 0)
    return EINVAL;

i.e. it constrains the SIZE argument instead of the ALIGN argument!  The
fix is, of course, trivial.

Thanks for your great work and perseverence on this important library; I
apologize if this bug has already been reported/fixed.

Cordially,
Steven G. Johnson





reply via email to

[Prev in Thread] Current Thread [Next in Thread]