DO NOT REPLY [Bug 44702] New: Calculation in LocalVariableTable. getLocalVariable is incorrect

2008-03-28 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44702

   Summary: Calculation in LocalVariableTable.getLocalVariable is
incorrect
   Product: BCEL
   Version: 5.3
  Platform: Macintosh
OS/Version: Mac OS X 10.4
Status: NEW
  Severity: normal
  Priority: P2
 Component: Main
AssignedTo: bcel-dev@jakarta.apache.org
ReportedBy: [EMAIL PROTECTED]


Created an attachment (id=21732)
 -- (https://issues.apache.org/bugzilla/attachment.cgi?id=21732)
Patch to fix bug

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.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44702] Calculation in LocalVariableTable. getLocalVariable is incorrect

2008-03-28 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44702


Torsten Curdt [EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |ASSIGNED




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r642421 - /jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java

2008-03-28 Thread tcurdt
Author: tcurdt
Date: Fri Mar 28 16:11:28 2008
New Revision: 642421

URL: http://svn.apache.org/viewvc?rev=642421view=rev
Log:
https://issues.apache.org/bugzilla/show_bug.cgi?id=44702

Thanks to William Pugh [EMAIL PROTECTED]


Modified:

jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java

Modified: 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java
URL: 
http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java?rev=642421r1=642420r2=642421view=diff
==
--- 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java
 (original)
+++ 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTable.java
 Fri Mar 28 16:11:28 2008
@@ -145,7 +145,7 @@
 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)) {
+if ((pc = start_pc)  (pc = end_pc)) {
 return local_variable_table[i];
 }
 }



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DO NOT REPLY [Bug 44702] Calculation in LocalVariableTable. getLocalVariable is incorrect

2008-03-28 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=44702


Torsten Curdt [EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED




--- Comment #1 from Torsten Curdt [EMAIL PROTECTED]  2008-03-28 16:10:25 PST 
---
Patch applied. Thanks!


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]