patch from Eric Ladner to correct an out of bounds on the formula string
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10735 PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8a9cfa0c2
commit
7aad8fe0e2
@ -79,6 +79,7 @@ import org.apache.poi.hssf.record.formula.*;
|
|||||||
*
|
*
|
||||||
* @author Avik Sengupta <avik AT Avik Sengupta DOT com>
|
* @author Avik Sengupta <avik AT Avik Sengupta DOT com>
|
||||||
* @author Andrew C. oliver (acoliver at apache dot org)
|
* @author Andrew C. oliver (acoliver at apache dot org)
|
||||||
|
* @author Eric Ladner (eladner at goldinc dot com)
|
||||||
*/
|
*/
|
||||||
public class FormulaParser {
|
public class FormulaParser {
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ public class FormulaParser {
|
|||||||
|
|
||||||
private String formulaString;
|
private String formulaString;
|
||||||
private int pointer=0;
|
private int pointer=0;
|
||||||
|
private int formulaLength;
|
||||||
|
|
||||||
private List tokens = new java.util.Stack();
|
private List tokens = new java.util.Stack();
|
||||||
//private Stack tokens = new java.util.Stack();
|
//private Stack tokens = new java.util.Stack();
|
||||||
@ -113,11 +115,19 @@ public class FormulaParser {
|
|||||||
formulaString = formula;
|
formulaString = formula;
|
||||||
pointer=0;
|
pointer=0;
|
||||||
this.book = book;
|
this.book = book;
|
||||||
|
formulaLength = formulaString.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Read New Character From Input Stream */
|
/** Read New Character From Input Stream */
|
||||||
private void GetChar() {
|
private void GetChar() {
|
||||||
|
// Check to see if we've walked off the end of the string.
|
||||||
|
// Just return if so and reset Look to smoething to keep
|
||||||
|
// SkipWhitespace from spinning
|
||||||
|
if (pointer == formulaLength) {
|
||||||
|
Look = (char)0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
Look=formulaString.charAt(pointer++);
|
Look=formulaString.charAt(pointer++);
|
||||||
//System.out.println("Got char: "+Look);
|
//System.out.println("Got char: "+Look);
|
||||||
}
|
}
|
||||||
@ -420,8 +430,8 @@ public class FormulaParser {
|
|||||||
while (IsAddop(Look)) {
|
while (IsAddop(Look)) {
|
||||||
if ( Look == '+' ) Add();
|
if ( Look == '+' ) Add();
|
||||||
if (Look == '-') Subtract();
|
if (Look == '-') Subtract();
|
||||||
// if (Look == '*') Multiply();
|
if (Look == '*') Multiply();
|
||||||
// if (Look == '/') Divide();
|
if (Look == '/') Divide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user