Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
410:8fb16f199266 | 413:c7ec737733a6 |
---|---|
26 # include "incls/_bytecodeStream.cpp.incl" | 26 # include "incls/_bytecodeStream.cpp.incl" |
27 | 27 |
28 Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) { | 28 Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) { |
29 assert(!is_last_bytecode(), "should have been checked"); | 29 assert(!is_last_bytecode(), "should have been checked"); |
30 // set next bytecode position | 30 // set next bytecode position |
31 address bcp = RawBytecodeStream::bcp(); | 31 address bcp = RawBytecodeStream::bcp(); |
32 int l = Bytecodes::raw_special_length_at(bcp); | 32 address end = method()->code_base() + end_bci(); |
33 int l = Bytecodes::raw_special_length_at(bcp, end); | |
33 if (l <= 0 || (_bci + l) > _end_bci) { | 34 if (l <= 0 || (_bci + l) > _end_bci) { |
34 code = Bytecodes::_illegal; | 35 code = Bytecodes::_illegal; |
35 } else { | 36 } else { |
36 _next_bci += l; | 37 _next_bci += l; |
37 assert(_bci < _next_bci, "length must be > 0"); | 38 assert(_bci < _next_bci, "length must be > 0"); |
38 // set attributes | 39 // set attributes |
39 _is_wide = false; | 40 _is_wide = false; |
40 // check for special (uncommon) cases | 41 // check for special (uncommon) cases |
41 if (code == Bytecodes::_wide) { | 42 if (code == Bytecodes::_wide) { |
42 code = (Bytecodes::Code)bcp[1]; | 43 if (bcp + 1 >= end) { |
43 _is_wide = true; | 44 code = Bytecodes::_illegal; |
45 } else { | |
46 code = (Bytecodes::Code)bcp[1]; | |
47 _is_wide = true; | |
48 } | |
44 } | 49 } |
45 } | 50 } |
46 _code = code; | 51 _code = code; |
47 return code; | 52 return code; |
48 } | 53 } |