Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Nov 2011 14:11:42 +0000 (UTC)
From:      David Chisnall <theraven@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r227818 - head/lib/libc/locale
Message-ID:  <201111221411.pAMEBg4d094247@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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]);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111221411.pAMEBg4d094247>