This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/9817: collate::compare doesn't handle nul characters.


>Number:         9817
>Category:       libstdc++
>Synopsis:       collate::compare doesn't handle nul characters.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 23 12:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02 at ru dot is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
collate::compare stops when it finds a nul character in the string, thus the strings "a\0a" and "a\0b" compare equal.
>How-To-Repeat:
See attachment.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="collatebug.cc"
Content-Disposition: inline; filename="collatebug.cc"

#include <locale>

#undef NDEBUG
#include <cassert>

int main()
{
	using namespace std;
	typedef collate<char> collate_type;

	locale loc = locale::classic();
	const collate_type& coll = use_facet<collate_type>(loc);

	char str1[] = { 'a', '\0', 'a' };
	char str2[] = { 'a', '\0', 'b' };

	assert(coll.compare(str1, str1 + 3, str2, str2 + 3) < 0);
	return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]