提交 7bd1df28 编写于 作者: L luchsh

7190219: (bf) CharBuffer.put(String,int,int) modifies position even if...

7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
Reviewed-by: alanb
上级 1973f4cd
......@@ -888,6 +888,8 @@ public abstract class $Type$Buffer
*/
public $Type$Buffer put(String src, int start, int end) {
checkBounds(start, end - start, src.length());
if (end - start > remaining())
throw new BufferOverflowException();
for (int i = start; i < end; i++)
this.put(src.charAt(i));
return this;
......
......@@ -402,6 +402,19 @@ public class Basic$Type$
ck(b, b.charAt(1), 'f');
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]
// Compact
......
......@@ -25,7 +25,7 @@
* @summary Unit test for buffers
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
* 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
*/
......
......@@ -396,6 +396,19 @@ public class BasicByte
......
......@@ -402,6 +402,19 @@ public class BasicChar
ck(b, b.charAt(1), 'f');
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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册