Skip to content

Instantly share code, notes, and snippets.

@nahi
Created March 23, 2012 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahi/2171719 to your computer and use it in GitHub Desktop.
Save nahi/2171719 to your computer and use it in GitHub Desktop.
diff --git a/src/org/jruby/ext/zlib/RubyZlib.java b/src/org/jruby/ext/zlib/RubyZlib.java
index a056cb8..65bae2f 100644
--- a/src/org/jruby/ext/zlib/RubyZlib.java
+++ b/src/org/jruby/ext/zlib/RubyZlib.java
@@ -1348,8 +1348,12 @@ public class RubyZlib {
public IRubyObject rewind() {
Ruby rt = getRuntime();
// should invoke seek on realIo...
+ long n = io.getTotalIn();
+ if (io.getAvailIn() != null) {
+ n += io.getAvailIn().length;
+ }
realIo.callMethod(rt.getCurrentContext(), "seek",
- new IRubyObject[]{rt.newFixnum(-io.getTotalIn()), rt.newFixnum(Stream.SEEK_CUR)});
+ new IRubyObject[]{rt.newFixnum(-n), rt.newFixnum(Stream.SEEK_CUR)});
// ... and then reinitialize
initialize(realIo);
return getRuntime().getNil();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment