From b23afbb1d859a79a2682a80420a7f3c693b210e6 Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 30 May 2006 00:56:35 +0200 Subject: [PATCH] wng: fix two critical bugs the open functions of the writers in a writer node group might be interested to know which group they belong to. Unfortunately, the old code called open before initializing the "wng" pointer of the writer node. The second bug triggers for example if invalid receiver options are given. In this case wng_close() is called with a NULL-argument as the wng has not been opened yet. The solution is to check for NULL pointers and return immediately in this case. --- write_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/write_common.c b/write_common.c index cfdabe48..39f124f8 100644 --- a/write_common.c +++ b/write_common.c @@ -58,15 +58,15 @@ int wng_open(struct writer_node_group *g) { int i, ret = 1; - PARA_NOTICE_LOG("opening wng with %d writer(s)\n", g->num_writers); + PARA_NOTICE_LOG("opening wng %p with %d writer(s)\n", g, g->num_writers); FOR_EACH_WRITER_NODE(i, g) { struct writer_node *wn = &g->writer_nodes[i]; + wn->wng = g; ret = wn->writer->open(wn); if (ret < 0) goto out; wn->chunk_bytes = ret; g->max_chunk_bytes = PARA_MAX(g->max_chunk_bytes, ret); - wn->wng = g; PARA_DEBUG_LOG("pre_select: %p\n", &wn->writer->pre_select); PARA_DEBUG_LOG("post_select: %p\n", &wn->writer->post_select); wn->task.pre_select = wn->writer->pre_select; @@ -94,6 +94,8 @@ void wng_close(struct writer_node_group *g) { int i; + if (!g) + return; PARA_NOTICE_LOG("closing wng with %d writer(s)\n", g->num_writers); FOR_EACH_WRITER_NODE(i, g) { struct writer_node *wn = &g->writer_nodes[i]; -- 2.39.2