1.c (test01): Clarify size definition.

2010-04-27  Alexander Monakov  <amonakov@ispras.ru>

	* testsuite/22_locale/codecvt/unshift/char/1.c (test01): Clarify size
	definition.  Use memcpy and memcmp to avoid access beyond allocated
	memory.

From-SVN: r158780
This commit is contained in:
Alexander Monakov 2010-04-27 16:00:35 +04:00 committed by Alexander Monakov
parent ecb9d36fe8
commit 9942526503
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2010-04-27 Alexander Monakov <amonakov@ispras.ru>
* testsuite/22_locale/codecvt/unshift/char/1.c (test01): Clarify size
definition. Use memcpy and memcmp to avoid access beyond allocated
memory.
2010-04-27 Jonathan Wakely <jwakely.gcc@gmail.com>
* doc/xml/manual/status_cxx200x.xml: Update to match n3092.

View File

@ -35,7 +35,7 @@ void test01()
bool test __attribute__((unused)) = true;
const char* c_lit = "black pearl jasmine tea";
const char* from_next;
int size = 23;
int size = std::strlen(c_lit);
char* c_arr = new char[size];
char* c_ref = new char[size];
char* to_next;
@ -68,10 +68,10 @@ void test01()
VERIFY( to_next == c_arr );
// unshift
strcpy(c_arr, c_lit);
memcpy(c_arr, c_lit, size);
result r3 = cvt->unshift(state, c_arr, c_arr + size, to_next);
VERIFY( r3 == codecvt_base::noconv );
VERIFY( !strcmp(c_arr, c_lit) );
VERIFY( !memcmp(c_arr, c_lit, size) );
VERIFY( to_next == c_arr );
delete [] c_arr;