# HG changeset patch # User zgu # Date 1364913652 25200 # Node ID a4e8dac9db8c06e00f72e582665870a2976ac369 # Parent ede380e1396034c6e03ba85e42b40b4667470890# Parent 8c03fc47511d24cdbf161c1b2bffb7723e1420c4 Merge diff -r ede380e13960 -r a4e8dac9db8c src/share/vm/oops/symbol.cpp --- a/src/share/vm/oops/symbol.cpp Tue Apr 02 11:28:33 2013 +0200 +++ b/src/share/vm/oops/symbol.cpp Tue Apr 02 07:40:52 2013 -0700 @@ -162,7 +162,7 @@ const char *ptr = (const char *)&_body[0]; int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length()); char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1); - UTF8::as_quoted_ascii(ptr, result, quoted_length + 1); + UTF8::as_quoted_ascii(ptr, utf8_length(), result, quoted_length + 1); return result; } diff -r ede380e13960 -r a4e8dac9db8c src/share/vm/utilities/utf8.cpp --- a/src/share/vm/utilities/utf8.cpp Tue Apr 02 11:28:33 2013 +0200 +++ b/src/share/vm/utilities/utf8.cpp Tue Apr 02 07:40:52 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,11 +180,12 @@ } // converts a utf8 string to quoted ascii -void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { +void UTF8::as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen) { const char *ptr = utf8_str; + const char *utf8_end = ptr + utf8_length; char* p = buf; char* end = buf + buflen; - while (*ptr != '\0') { + while (ptr < utf8_end) { jchar c; ptr = UTF8::next(ptr, &c); if (c >= 32 && c < 127) { @@ -196,6 +197,7 @@ p += 6; } } + assert(p < end, "sanity"); *p = '\0'; } diff -r ede380e13960 -r a4e8dac9db8c src/share/vm/utilities/utf8.hpp --- a/src/share/vm/utilities/utf8.hpp Tue Apr 02 11:28:33 2013 +0200 +++ b/src/share/vm/utilities/utf8.hpp Tue Apr 02 07:40:52 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ static int quoted_ascii_length(const char* utf8_str, int utf8_length); // converts a utf8 string to quoted ascii - static void as_quoted_ascii(const char* utf8_str, char* buf, int buflen); + static void as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen); // converts a quoted ascii string to utf8 string. returns the original // string unchanged if nothing needs to be done.