"".unpack("u") blows up
-----------------------

                 Key: JRUBY-6052
                 URL: https://jira.codehaus.org/browse/JRUBY-6052
             Project: JRuby
          Issue Type: Bug
            Reporter: Yusuke Endoh
            Assignee: Thomas E Enebo


$ bin/jruby --1.9 -e 'p "".unpack("u")'
Buffer.java:474:in `nextGetIndex': java.nio.BufferUnderflowException
*snip*


diff --git a/src/org/jruby/util/Pack.java b/src/org/jruby/util/Pack.java
index 8c38d5d..a1bb2f8 100644
--- a/src/org/jruby/util/Pack.java
+++ b/src/org/jruby/util/Pack.java
@@ -999,9 +999,9 @@ public class Pack {
                     int length = encode.remaining() * 3 / 4;
                     byte[] lElem = new byte[length];
                     int index = 0;
-                    int s;
+                    int s = 0;
                     int total = 0;
-                    s = encode.get();
+                    if (length > 0) s = encode.get();
                     while (encode.hasRemaining() && s > ' ' && s < 'a') {
                         int a, b, c, d;
                         byte[] hunk = new byte[3];

-- 
Yusuke Endoh <m...@tsg.ne.jp>

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to