From 697e4bc3c7ff473b2d0e080b22e42cf742c42432 Mon Sep 17 00:00:00 2001 From: moritz Date: Sun, 4 Mar 2007 15:59:06 +0000 Subject: [PATCH] Fix logic error and prevent an endless loop on error(s) in the config file. git-svn-id: https://svn.xiph.org/trunk/ezstream@12630 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- src/configfile.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/configfile.c b/src/configfile.c index a1a0a05..cc54b36 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -168,8 +168,7 @@ parseConfig(const char *fileName) shuffle_set = 0; streamOnce_set = 0; svrinfopublic_set = 0; - cur = cur->xmlChildrenNode; - while (cur != NULL) { + for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) { if (!xmlStrcmp(cur->name, BAD_CAST "url")) { if (ezConfig.URL != NULL) { printf("%s[%ld]: Error: Cannot have multiple elements\n", @@ -452,8 +451,8 @@ parseConfig(const char *fileName) int enable_set; enable_set = 0; - cur2 = cur->xmlChildrenNode; - while (cur2 != NULL) { + for (cur2 = cur->xmlChildrenNode; cur2 != NULL; + cur2 = cur2->next) { if (!xmlStrcmp(cur2->name, BAD_CAST "enable")) { if (enable_set) { printf("%s[%ld]: Error: Cannot have multiple elements\n", @@ -483,8 +482,8 @@ parseConfig(const char *fileName) pformatEncDec = xcalloc(1, sizeof(FORMAT_ENCDEC)); - cur3 = cur2->xmlChildrenNode; - while (cur3 != NULL) { + for (cur3 = cur2->xmlChildrenNode; + cur3 != NULL; cur3 = cur3->next) { if (!xmlStrcmp(cur3->name, BAD_CAST "format")) { if (pformatEncDec->format != NULL) { printf("%s[%ld]: Error: Cannot have multiple elements\n", @@ -578,15 +577,12 @@ parseConfig(const char *fileName) } } } - cur3 = cur3->next; } ezConfig.encoderDecoders[ezConfig.numEncoderDecoders] = pformatEncDec; ezConfig.numEncoderDecoders++; } - cur2 = cur2->next; } } - cur = cur->next; } xmlFreeDoc(doc);