From owner-svn-src-all@FreeBSD.ORG Tue Nov 22 14:11:42 2011 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 80C451065670; Tue, 22 Nov 2011 14:11:42 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7051E8FC08; Tue, 22 Nov 2011 14:11:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAMEBg7c094249; Tue, 22 Nov 2011 14:11:42 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAMEBg4d094247; Tue, 22 Nov 2011 14:11:42 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111221411.pAMEBg4d094247@svn.freebsd.org> From: David Chisnall Date: Tue, 22 Nov 2011 14:11:42 +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: r227818 - head/lib/libc/locale 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: Tue, 22 Nov 2011 14:11:42 -0000 Author: theraven Date: Tue Nov 22 14:11:42 2011 New Revision: 227818 URL: http://svn.freebsd.org/changeset/base/227818 Log: Fix a crash when trying to duplicate a locale that contains some implicit C locale components. Reported by: Michael Butler Approved by: dim (mentor) Modified: head/lib/libc/locale/xlocale.c Modified: head/lib/libc/locale/xlocale.c ============================================================================== --- head/lib/libc/locale/xlocale.c Tue Nov 22 13:30:36 2011 (r227817) +++ head/lib/libc/locale/xlocale.c Tue Nov 22 14:11:42 2011 (r227818) @@ -200,8 +200,13 @@ static int dupcomponent(int type, locale if (new->components[type]) { strncpy(new->components[type]->locale, src->locale, ENCODING_LEN); } - } else { + } else if (base->components[type]) { new->components[type] = xlocale_retain(base->components[type]); + } else { + /* If the component was NULL, return success - if base is a valid + * locale then the flag indicating that this isn't present should be + * set. If it isn't a valid locale, then we're stuck anyway. */ + return 1; } return (0 != new->components[type]); }