Permalink
Browse files

Fix an IOOBE - JRUBY-4254

  • Loading branch information...
1 parent d665cd6 commit 853d9041790c833bbf6c8c06d3272c759926e531 @olabini committed Nov 22, 2009
Showing with 5 additions and 1 deletion.
  1. +5 −1 ext/ruby/src/java/org/yecht/ruby/RubyErrHandler.java
View
6 ext/ruby/src/java/org/yecht/ruby/RubyErrHandler.java
@@ -25,7 +25,11 @@ public void handle(Parser p, String msg) {
if(lp < 0) {
lp = 0;
}
- String line = new String(p.buffer.buffer, lp, endl-lp, "ISO-8859-1");
+ int len = endl-lp;
+ if(len < 0) {
+ len = 0;
+ }
+ String line = new String(p.buffer.buffer, lp, len, "ISO-8859-1");
String m1 = msg + " on line " + p.linect + ", col " + (p.cursor-lp) + ": `" + line + "'";
throw runtime.newArgumentError(m1);
} catch(java.io.UnsupportedEncodingException e) {

0 comments on commit 853d904

Please sign in to comment.