diff src/share/vm/interpreter/bytecodeStream.cpp @ 413:c7ec737733a6

6756528: Bytecodes::special_length_at reads past end of code buffer Summary: Add end-of-buffer indicator for paths used by the verifier Reviewed-by: acorn, coleenp
author kamg
date Thu, 30 Oct 2008 15:48:59 -0400
parents a61af66fc99e
children ad8c8ca4ab0f
line wrap: on
line diff
--- a/src/share/vm/interpreter/bytecodeStream.cpp	Wed Oct 22 20:47:00 2008 -0700
+++ b/src/share/vm/interpreter/bytecodeStream.cpp	Thu Oct 30 15:48:59 2008 -0400
@@ -28,8 +28,9 @@
 Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) {
   assert(!is_last_bytecode(), "should have been checked");
   // set next bytecode position
-  address bcp  = RawBytecodeStream::bcp();
-  int l = Bytecodes::raw_special_length_at(bcp);
+  address bcp = RawBytecodeStream::bcp();
+  address end = method()->code_base() + end_bci();
+  int l = Bytecodes::raw_special_length_at(bcp, end);
   if (l <= 0 || (_bci + l) > _end_bci) {
     code = Bytecodes::_illegal;
   } else {
@@ -39,8 +40,12 @@
     _is_wide = false;
     // check for special (uncommon) cases
     if (code == Bytecodes::_wide) {
-      code = (Bytecodes::Code)bcp[1];
-      _is_wide = true;
+      if (bcp + 1 >= end) {
+        code = Bytecodes::_illegal;
+      } else {
+        code = (Bytecodes::Code)bcp[1];
+        _is_wide = true;
+      }
     }
   }
   _code = code;