[xiph-commits] r8153 - trunk/vorbis-tools/oggdec
msmith at motherfish-iii.xiph.org
msmith at motherfish-iii.xiph.org
Sun Oct 31 15:45:50 PST 2004
Author: msmith
Date: 2004-10-31 15:45:49 -0800 (Sun, 31 Oct 2004)
New Revision: 8153
Modified:
trunk/vorbis-tools/oggdec/oggdec.c
Log:
Ensure ov_open() succeeds before opening the output file.
This has two benefits: it avoids creating useless zero-length files if the
input is invalid, and prevents data losss (bug #579) if the input and output
filenames are identical and the file unopenable.
Modified: trunk/vorbis-tools/oggdec/oggdec.c
===================================================================
--- trunk/vorbis-tools/oggdec/oggdec.c 2004-10-30 21:47:29 UTC (rev 8152)
+++ trunk/vorbis-tools/oggdec/oggdec.c 2004-10-31 23:45:49 UTC (rev 8153)
@@ -201,6 +201,13 @@
}
}
+
+ if(ov_open(in, &vf, NULL, 0) < 0) {
+ fprintf(stderr, "ERROR: Failed to open input as vorbis\n");
+ fclose(in);
+ return 1;
+ }
+
if(!outfile) {
#ifdef __BORLANDC__
setmode(fileno(stdout), O_BINARY);
@@ -217,13 +224,6 @@
}
}
- if(ov_open(in, &vf, NULL, 0) < 0) {
- fprintf(stderr, "ERROR: Failed to open input as vorbis\n");
- fclose(in);
- fclose(out);
- return 1;
- }
-
if(ov_seekable(&vf)) {
seekable = 1;
length = ov_pcm_total(&vf, 0);
More information about the commits
mailing list