From owner-svn-src-all@FreeBSD.ORG Sun Jan 24 20:15:59 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4117106566B; Sun, 24 Jan 2010 20:15:59 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D27EF8FC0C; Sun, 24 Jan 2010 20:15:59 +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 o0OKFxKW032002; Sun, 24 Jan 2010 20:15:59 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0OKFx3U032000; Sun, 24 Jan 2010 20:15:59 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201001242015.o0OKFx3U032000@svn.freebsd.org> From: David Schultz Date: Sun, 24 Jan 2010 20:15:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202947 - stable/8/lib/libc/stdio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2010 20:16:00 -0000 Author: das Date: Sun Jan 24 20:15:59 2010 New Revision: 202947 URL: http://svn.freebsd.org/changeset/base/202947 Log: MFC r197752: Better glibc compatibility for getline/getdelim: - Tolerate applications that pass a NULL pointer for the buffer and claim that the capacity of the buffer is nonzero. - If an application passes in a non-NULL buffer pointer and claims the buffer has zero capacity, we should free (well, realloc) it anyway. It could have been obtained from malloc(0), so failing to free it would be a small memory leak. Modified: stable/8/lib/libc/stdio/getdelim.c Modified: stable/8/lib/libc/stdio/getdelim.c ============================================================================== --- stable/8/lib/libc/stdio/getdelim.c Sun Jan 24 19:36:43 2010 (r202946) +++ stable/8/lib/libc/stdio/getdelim.c Sun Jan 24 20:15:59 2010 (r202947) @@ -120,8 +120,8 @@ getdelim(char ** __restrict linep, size_ goto error; } - if (*linecapp == 0) - *linep = NULL; + if (*linep == NULL) + *linecapp = 0; if (fp->_r <= 0 && __srefill(fp)) { /* If fp is at EOF already, we just need space for the NUL. */