Subject: | segfault when open fails |
Hi,
perl -e 'use Ogg::Vorbis::Decoder;
Ogg::Vorbis::Decoder->open("no-such-file.ogg")'
This segfaults on me.
(Sometimes open with a nonexistent filename succeeds without segfault,
it's quite unreproducable. Try to put it in different places in a large
script if you can't reproduce it.)
I think this is because Decoder.xs calls ov_clear after open(2) fails,
however, the vorbisfile structure hasn't been initialized by that time.
It's uninitialized memory, and I think that is the reason for the
random segfaults.
The attached patch fixes the problem for me.
Subject: | vorbis-ovclear.patch |
--- Ogg-Vorbis-Decoder-0.8/Decoder.xs~ 2009-01-21 18:58:10.994456836 +0100
+++ Ogg-Vorbis-Decoder-0.8/Decoder.xs 2009-01-21 18:58:20.154455706 +0100
@@ -194,7 +194,7 @@
if (SvOK(path) && (SvTYPE(SvRV(path)) != SVt_PVGV)) {
if ((datasource->stream = PerlIO_open((char*)SvPV_nolen(path), "r")) == NULL) {
- ov_clear(vf);
+ safefree(vf);
printf("failed on open: [%d] - [%s]\n", errno, strerror(errno));
XSRETURN_UNDEF;
}