[ 
https://issues.apache.org/jira/browse/BCEL-121?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alex Herbert updated BCEL-121:
------------------------------
    Priority: Minor

> Calculation in LocalVariableTable.getLocalVariable is incorrect
> ---------------------------------------------------------------
>
>                 Key: BCEL-121
>                 URL: https://issues.apache.org/jira/browse/BCEL-121
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: 5.3
>         Environment: Operating System: Mac OS X 10.4
> Platform: Macintosh
>            Reporter: William Pugh
>            Assignee: Apache Commons Developers
>            Priority: Minor
>         Attachments: patch.txt
>
>
> The calculation in LocalVariableTable.getLocalVariable is incorrect:
>  public final LocalVariable getLocalVariable( int index, int pc ) {
>         for (int i = 0; i < local_variable_table_length; i++) {
>             if (local_variable_table[i].getIndex() == index) {
>                 int start_pc = local_variable_table[i].getStartPC();
>                 int end_pc = start_pc + local_variable_table[i].getLength();
>                 if ((pc >= start_pc) && (pc < end_pc)) {
>                     return local_variable_table[i];
>                 }
>             }
>         }
>         return null;
>     }
> From the VM spec:
> "The given local variable must have a value at indices into the code array in 
> the interval [start_pc, start_pc+length], that is, between start_pc and 
> start_pc+length inclusive. The value of start_pc must be a valid index into 
> the code array of this Code attribute and must be the index of the opcode of 
> an instruction. Either the value of start_pc+length must be a valid index 
> into the code array of this Code attribute and be the index of the opcode of 
> an instruction, or it must be the first index beyond the end of that code 
> array."
> The check should be pc <= end_pc, not pc < end_pc.
> This problem exists both in HEAD and in older versions.
> I've attached a patch.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to