changeset 21011:b3fbda23e570

move demux_nut priv calloc to init() instead of check_file()
author ods15
date Sat, 18 Nov 2006 15:17:50 +0000
parents b4c52b9460fb
children 738a492561e2
files libmpdemux/demux_nut.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_nut.c	Sat Nov 18 14:47:53 2006 +0000
+++ b/libmpdemux/demux_nut.c	Sat Nov 18 15:17:50 2006 +0000
@@ -48,7 +48,6 @@
 
 static int nut_check_file(demuxer_t * demuxer) {
 	uint8_t buf[ID_LENGTH];
-	nut_priv_t * priv = demuxer->priv = calloc(1, sizeof(nut_priv_t));
 
 	if (stream_read(demuxer->stream, buf, ID_LENGTH) != ID_LENGTH) return 0;
 
@@ -72,7 +71,7 @@
 		.read_index = index_mode,
 		.cache_syncpoints = 1,
 	};
-	nut_priv_t * priv = demuxer->priv;
+	nut_priv_t * priv = demuxer->priv = calloc(1, sizeof(nut_priv_t));
 	nut_context_t * nut = priv->nut = nut_demuxer_init(&dopts);
 	nut_stream_header_t * s;
 	int ret;
@@ -276,6 +275,7 @@
 
 static void demux_close_nut(demuxer_t *demuxer) {
 	nut_priv_t * priv = demuxer->priv;
+	if (!priv) return;
 	nut_demuxer_uninit(priv->nut);
 	free(demuxer->priv);
 	demuxer->priv = NULL;