mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 04:24:49 +02:00
7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
Reviewed-by: alanb
This commit is contained in:
parent
d947b5d95a
commit
f349c3da24
10 changed files with 107 additions and 1 deletions
|
@ -888,6 +888,8 @@ public abstract class $Type$Buffer
|
||||||
*/
|
*/
|
||||||
public $Type$Buffer put(String src, int start, int end) {
|
public $Type$Buffer put(String src, int start, int end) {
|
||||||
checkBounds(start, end - start, src.length());
|
checkBounds(start, end - start, src.length());
|
||||||
|
if (end - start > remaining())
|
||||||
|
throw new BufferOverflowException();
|
||||||
for (int i = start; i < end; i++)
|
for (int i = start; i < end; i++)
|
||||||
this.put(src.charAt(i));
|
this.put(src.charAt(i));
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -402,6 +402,19 @@ public class Basic$Type$
|
||||||
ck(b, b.charAt(1), 'f');
|
ck(b, b.charAt(1), 'f');
|
||||||
ck(b, b.subSequence(1, 3).toString().equals("fg"));
|
ck(b, b.subSequence(1, 3).toString().equals("fg"));
|
||||||
|
|
||||||
|
// String ops
|
||||||
|
|
||||||
|
// 7190219
|
||||||
|
b.clear();
|
||||||
|
int pos = b.position();
|
||||||
|
tryCatch(b, BufferOverflowException.class, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
b.put(String.valueOf(new char[b.capacity() + 1]), 0,
|
||||||
|
b.capacity() + 1);
|
||||||
|
}});
|
||||||
|
ck(b, b.position(), pos);
|
||||||
|
relGet(b);
|
||||||
|
|
||||||
#end[char]
|
#end[char]
|
||||||
|
|
||||||
// Compact
|
// Compact
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* @summary Unit test for buffers
|
* @summary Unit test for buffers
|
||||||
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
|
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
|
||||||
* 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529
|
* 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529
|
||||||
* 6221101 6234263 6535542 6591971 6593946 6795561
|
* 6221101 6234263 6535542 6591971 6593946 6795561 7190219
|
||||||
* @author Mark Reinhold
|
* @author Mark Reinhold
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,19 @@ public class BasicByte
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -402,6 +402,19 @@ public class BasicChar
|
||||||
ck(b, b.charAt(1), 'f');
|
ck(b, b.charAt(1), 'f');
|
||||||
ck(b, b.subSequence(1, 3).toString().equals("fg"));
|
ck(b, b.subSequence(1, 3).toString().equals("fg"));
|
||||||
|
|
||||||
|
// String ops
|
||||||
|
|
||||||
|
// 7190219
|
||||||
|
b.clear();
|
||||||
|
int pos = b.position();
|
||||||
|
tryCatch(b, BufferOverflowException.class, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
b.put(String.valueOf(new char[b.capacity() + 1]), 0,
|
||||||
|
b.capacity() + 1);
|
||||||
|
}});
|
||||||
|
ck(b, b.position(), pos);
|
||||||
|
relGet(b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Compact
|
// Compact
|
||||||
|
|
|
@ -396,6 +396,19 @@ public class BasicDouble
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,19 @@ public class BasicFloat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,19 @@ public class BasicInt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,19 @@ public class BasicLong
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,19 @@ public class BasicShort
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue