diff --git a/src/ucil_theora.c b/src/ucil_theora.c
index 0919a97..e2d00ef 100644
--- a/src/ucil_theora.c
+++ b/src/ucil_theora.c
@@ -1556,7 +1556,11 @@ ucil_theora_video_file_object_t *ucil_theora_create_video_filev( const char *pat
#endif
- theora_encode_init( &vobj->th, &vobj->ti );
+ if( theora_encode_init( &vobj->th, &vobj->ti ) != 0)
+ {
+ free( vobj );
+ return NULL;
+ }
vobj->full_queue = g_queue_new();
vobj->empty_queue = g_queue_new();