Skip to content

Conversation

@noahhaon
Copy link

bz_reader_read never frees any of the buffers it allocates for uncompressed data.

I found this behavior to be sub-optimal so I made it free the buffers before returning the ruby string. Probably a better way to do this, but at least Bzip2.uncompress doesn't leak anymore...

brianmario added a commit that referenced this pull request Sep 12, 2012
Fix memory leak in bz_reader_read
@brianmario brianmario merged commit 3ed94da into brianmario:master Sep 12, 2012
@chewi
Copy link
Contributor

chewi commented Jan 15, 2014

@brianmario, you may need to re-re-revert this! 😁 It's causing "double free" segfaults for me on both Fedora 20 and CentOS 6.3. However, it only happens when I'm piping it through ruby-gpgme.

@brianmario
Copy link
Owner

The code in this gem is pretty bad. I'd recommend looking for alternatives. Unfortunately I haven't had any time to work on it. I wrote https://gist.github.com/brianmario/5833373 which only does a simple one-pass compress/decompress but you could use it as a starting point to build out an IO-like API.

Sorry for the trouble :\

@chewi
Copy link
Contributor

chewi commented Jan 15, 2014

Thanks for that, it looks like a good start. However bad it may be though, this gem does work for me. I did try switching to rbzip2 because I was looking at JRuby but it doesn't implement gets, which I need. I've shelved JRuby for the moment.

chewi added a commit to yakara-ltd/bzip2-ruby that referenced this pull request Feb 10, 2014
This reverts commit e58f154 because
the "fix" is causing double frees when piped through ruby-gpgme. See
issue brianmario#12.
@sodabrew
Copy link

sodabrew commented Jun 3, 2014

Oh, this is showing up in #27 builds on Travis. @brianmario is it unsalvageable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants