[xiph-commits] r12936 - trunk/theora/examples
giles at svn.xiph.org
giles at svn.xiph.org
Wed May 9 15:47:46 PDT 2007
Author: giles
Date: 2007-05-09 15:47:46 -0700 (Wed, 09 May 2007)
New Revision: 12936
Modified:
trunk/theora/examples/png2theora.c
Log:
Correct a segfault in the error handling.
Modified: trunk/theora/examples/png2theora.c
===================================================================
--- trunk/theora/examples/png2theora.c 2007-05-09 20:17:02 UTC (rev 12935)
+++ trunk/theora/examples/png2theora.c 2007-05-09 22:47:46 UTC (rev 12936)
@@ -55,7 +55,7 @@
static int theora_initialized = 0;
-static FILE *ogg_fp;
+static FILE *ogg_fp = NULL;
static ogg_stream_state ogg_os;
static theora_state theora_td;
@@ -254,20 +254,22 @@
{
ogg_packet op;
ogg_page og;
+
+ if (theora_initialized) {
+ theora_encode_packetout(&theora_td, 1, &op);
+ if(ogg_stream_pageout(&ogg_os, &og)) {
+ fwrite(og.header, og.header_len, 1, ogg_fp);
+ fwrite(og.body, og.body_len, 1, ogg_fp);
+ }
- theora_encode_packetout(&theora_td, 1, &op);
- if(ogg_stream_pageout(&ogg_os, &og)) {
- fwrite(og.header, og.header_len, 1, ogg_fp);
- fwrite(og.body, og.body_len, 1, ogg_fp);
+ theora_info_clear(&theora_ti);
+ theora_clear(&theora_td);
+
+ fflush(ogg_fp);
+ fclose(ogg_fp);
}
- theora_info_clear(&theora_ti);
- theora_clear(&theora_td);
-
ogg_stream_clear(&ogg_os);
-
- fflush(ogg_fp);
- fclose(ogg_fp);
}
static unsigned char
@@ -472,8 +474,7 @@
sprintf(input_png, "%s/%s", input_directory, png_files[i]->d_name);
if(png_read(input_png, &w, &h, &yuv)) {
- if(theora_initialized)
- theora_close();
+ theora_close();
exit(1);
}
More information about the commits
mailing list