From owner-svn-src-head@FreeBSD.ORG Sat Sep 5 13:32:05 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBD671065670; Sat, 5 Sep 2009 13:32:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BB6748FC16; Sat, 5 Sep 2009 13:32:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85DW5Tq054298; Sat, 5 Sep 2009 13:32:05 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85DW5Q1054296; Sat, 5 Sep 2009 13:32:05 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200909051332.n85DW5Q1054296@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 Sep 2009 13:32:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196861 - head/lib/libc/stdlib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 13:32:05 -0000 Author: kib Date: Sat Sep 5 13:32:05 2009 New Revision: 196861 URL: http://svn.freebsd.org/changeset/base/196861 Log: Handle zero size for posix_memalign. Return NULL or unique address according to the 'V' option. PR: standards/138307 MFC after: 1 week Modified: head/lib/libc/stdlib/malloc.c Modified: head/lib/libc/stdlib/malloc.c ============================================================================== --- head/lib/libc/stdlib/malloc.c Sat Sep 5 13:31:16 2009 (r196860) +++ head/lib/libc/stdlib/malloc.c Sat Sep 5 13:32:05 2009 (r196861) @@ -5320,6 +5320,15 @@ posix_memalign(void **memptr, size_t ali goto RETURN; } + if (size == 0) { + if (opt_sysv == false) + size = 1; + else { + result = NULL; + ret = 0; + goto RETURN; + } + } result = ipalloc(alignment, size); }