hotspot/src/share/vm/interpreter/bytecodeStream.cpp
changeset 1493 7d2dc5fbfa8c
parent 1 489c9b5090e2
child 1623 a0dd9009e992
--- a/hotspot/src/share/vm/interpreter/bytecodeStream.cpp	Wed Oct 22 20:47:00 2008 -0700
+++ b/hotspot/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;