1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

end of first pass on coverity reports. Daniel

* runtest.c schematron.c testAutomata.c tree.c valid.c xinclude.c
  xmlcatalog.c xmlreader.c xmlregexp.c xpath.c: end of first
  pass on coverity reports.
Daniel
This commit is contained in:
Daniel Veillard
2006-03-10 00:36:23 +00:00
parent 14b5643947
commit 11ce4004d8
11 changed files with 116 additions and 63 deletions

View File

@ -1,3 +1,9 @@
Fri Mar 10 01:34:42 CET 2006 Daniel Veillard <daniel@veillard.com>
* runtest.c schematron.c testAutomata.c tree.c valid.c xinclude.c
xmlcatalog.c xmlreader.c xmlregexp.c xpath.c: end of first
pass on coverity reports.
Thu Mar 9 19:36:14 CET 2006 Daniel Veillard <daniel@veillard.com> Thu Mar 9 19:36:14 CET 2006 Daniel Veillard <daniel@veillard.com>
* relaxng.c xmlschemas.c xmlschemastypes.c: more cleanups based * relaxng.c xmlschemas.c xmlschemastypes.c: more cleanups based

View File

@ -617,7 +617,7 @@ static int compareFiles(const char *r1, const char *r2) {
while (1) { while (1) {
res1 = read(fd1, bytes1, 4096); res1 = read(fd1, bytes1, 4096);
res2 = read(fd2, bytes2, 4096); res2 = read(fd2, bytes2, 4096);
if (res1 != res2) { if ((res1 != res2) || (res1 < 0)) {
close(fd1); close(fd1);
close(fd2); close(fd2);
return(1); return(1);
@ -2545,7 +2545,7 @@ static void
handleURI(const char *str, const char *base, FILE *o) { handleURI(const char *str, const char *base, FILE *o) {
int ret; int ret;
xmlURIPtr uri; xmlURIPtr uri;
xmlChar *res = NULL, *parsed = NULL; xmlChar *res = NULL;
uri = xmlCreateURI(); uri = xmlCreateURI();
@ -2568,8 +2568,6 @@ handleURI(const char *str, const char *base, FILE *o) {
} }
if (res != NULL) if (res != NULL)
xmlFree(res); xmlFree(res);
if (parsed != NULL)
xmlFree(parsed);
xmlFreeURI(uri); xmlFreeURI(uri);
} }

View File

@ -1044,11 +1044,10 @@ done:
if (doc != NULL) if (doc != NULL)
xmlFreeDoc(doc); xmlFreeDoc(doc);
} }
if (href == NULL) xmlFree(href);
xmlFree(href); if (base != NULL)
if (base == NULL)
xmlFree(base); xmlFree(base);
if (URI == NULL) if (URI != NULL)
xmlFree(URI); xmlFree(URI);
return(ret); return(ret);
} }
@ -1207,13 +1206,15 @@ exit:
if (!preserve) { if (!preserve) {
xmlFreeDoc(doc); xmlFreeDoc(doc);
} }
if (ctxt->nberrors != 0) { if (ret != NULL) {
xmlSchematronFree(ret); if (ctxt->nberrors != 0) {
ret = NULL; xmlSchematronFree(ret);
} else { ret = NULL;
ret->namespaces = ctxt->namespaces; } else {
ret->nbNamespaces = ctxt->nbNamespaces; ret->namespaces = ctxt->namespaces;
ctxt->namespaces = NULL; ret->nbNamespaces = ctxt->nbNamespaces;
ctxt->namespaces = NULL;
}
} }
return (ret); return (ret);
} }
@ -1519,7 +1520,7 @@ xmlSchematronNextNode(xmlNodePtr cur) {
do { do {
cur = cur->parent; cur = cur->parent;
if (cur == NULL) return(NULL); if (cur == NULL) break;
if (cur->type == XML_DOCUMENT_NODE) return(NULL); if (cur->type == XML_DOCUMENT_NODE) return(NULL);
if (cur->next != NULL) { if (cur->next != NULL) {
cur = cur->next; cur = cur->next;

View File

@ -53,6 +53,7 @@ testRegexpFile(const char *filename) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"Cannot create automata\n"); "Cannot create automata\n");
fclose(input); fclose(input);
return;
} }
states[0] = xmlAutomataGetInitState(am); states[0] = xmlAutomataGetInitState(am);
if (states[0] == NULL) { if (states[0] == NULL) {
@ -60,6 +61,7 @@ testRegexpFile(const char *filename) {
"Cannot get start state\n"); "Cannot get start state\n");
xmlFreeAutomata(am); xmlFreeAutomata(am);
fclose(input); fclose(input);
return;
} }
ret = 0; ret = 0;

20
tree.c
View File

@ -5513,6 +5513,11 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
node->nsDef = cur; node->nsDef = cur;
return(cur); return(cur);
} }
if (doc == NULL) {
doc = node->doc;
if (doc == NULL)
return(NULL);
}
if (doc->oldNs == NULL) { if (doc->oldNs == NULL) {
/* /*
* Allocate a new Namespace and fill the fields. * Allocate a new Namespace and fill the fields.
@ -5650,6 +5655,11 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
node->nsDef = cur; node->nsDef = cur;
return (cur); return (cur);
} }
if (doc == NULL) {
doc = node->doc;
if (doc == NULL)
return(NULL);
}
if (doc->oldNs == NULL) { if (doc->oldNs == NULL) {
/* /*
* Allocate a new Namespace and fill the fields. * Allocate a new Namespace and fill the fields.
@ -8379,7 +8389,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
xmlNodePtr cur, curElem = NULL; xmlNodePtr cur, curElem = NULL;
xmlNsMapPtr nsMap = NULL; xmlNsMapPtr nsMap = NULL;
xmlNsMapItemPtr mi; xmlNsMapItemPtr mi;
xmlNsPtr ns; xmlNsPtr ns = NULL;
int depth = -1, adoptStr = 1; int depth = -1, adoptStr = 1;
/* gather @parent's ns-decls. */ /* gather @parent's ns-decls. */
int parnsdone = 0; int parnsdone = 0;
@ -8716,8 +8726,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
xmlNodePtr resultClone = NULL, clone = NULL, parentClone = NULL, prevClone = NULL; xmlNodePtr resultClone = NULL, clone = NULL, parentClone = NULL, prevClone = NULL;
xmlNsPtr cloneNs = NULL, *cloneNsDefSlot = NULL; xmlNsPtr cloneNs = NULL, *cloneNsDefSlot = NULL;
if ((node == NULL) || (resNode == NULL) || if ((node == NULL) || (resNode == NULL) || (destDoc == NULL))
(sourceDoc == NULL) || (destDoc == NULL))
return(-1); return(-1);
/* /*
* TODO: Initially we support only element-nodes. * TODO: Initially we support only element-nodes.
@ -8736,6 +8745,8 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
} }
if (sourceDoc == NULL) if (sourceDoc == NULL)
sourceDoc = node->doc; sourceDoc = node->doc;
if (sourceDoc == NULL)
return (-1);
*resNode = NULL; *resNode = NULL;
@ -9121,7 +9132,8 @@ leave_node:
/* /*
* Set clone->last. * Set clone->last.
*/ */
clone->parent->last = clone; if (clone->parent != NULL)
clone->parent->last = clone;
clone = clone->parent; clone = clone->parent;
parentClone = clone->parent; parentClone = clone->parent;
/* /*

View File

@ -4064,9 +4064,11 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
* element in the external subset. * element in the external subset.
*/ */
nbId = 0; nbId = 0;
table = (xmlAttributeTablePtr) doc->intSubset->attributes; if (doc->intSubset != NULL) {
xmlHashScan3(table, NULL, NULL, attr->elem, (xmlHashScanner) table = (xmlAttributeTablePtr) doc->intSubset->attributes;
xmlValidateAttributeIdCallback, &nbId); xmlHashScan3(table, NULL, NULL, attr->elem, (xmlHashScanner)
xmlValidateAttributeIdCallback, &nbId);
}
} }
if (nbId > 1) { if (nbId > 1) {

View File

@ -388,9 +388,11 @@ xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
if (ctxt->incTab[i] != NULL) if (ctxt->incTab[i] != NULL)
xmlXIncludeFreeRef(ctxt->incTab[i]); xmlXIncludeFreeRef(ctxt->incTab[i]);
} }
for (i = 0;i < ctxt->txtNr;i++) { if (ctxt->txturlTab != NULL) {
if (ctxt->txturlTab[i] != NULL) for (i = 0;i < ctxt->txtNr;i++) {
xmlFree(ctxt->txturlTab[i]); if (ctxt->txturlTab[i] != NULL)
xmlFree(ctxt->txturlTab[i]);
}
} }
if (ctxt->incTab != NULL) if (ctxt->incTab != NULL)
xmlFree(ctxt->incTab); xmlFree(ctxt->incTab);
@ -1401,9 +1403,14 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
URL = xmlSaveUri(uri); URL = xmlSaveUri(uri);
xmlFreeURI(uri); xmlFreeURI(uri);
if (URL == NULL) { if (URL == NULL) {
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, if (ctxt->incTab != NULL)
XML_XINCLUDE_HREF_URI, xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
"invalid value URI %s\n", url); XML_XINCLUDE_HREF_URI,
"invalid value URI %s\n", url);
else
xmlXIncludeErr(ctxt, NULL,
XML_XINCLUDE_HREF_URI,
"invalid value URI %s\n", url);
if (fragment != NULL) if (fragment != NULL)
xmlFree(fragment); xmlFree(fragment);
return(-1); return(-1);
@ -2315,10 +2322,7 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) {
if (ret < 0) if (ret < 0)
return(-1); return(-1);
} }
if (tree) start = ctxt->incNr;
start = ctxt->incNr;
else
start = ctxt->incBase;
/* /*
* First phase: lookup the elements in the document * First phase: lookup the elements in the document

View File

@ -120,7 +120,10 @@ static void usershell(void) {
command[i++] = *cur++; command[i++] = *cur++;
} }
command[i] = 0; command[i] = 0;
if (i == 0) continue; if (i == 0) {
free(cmdline);
continue;
}
nbargs++; nbargs++;
/* /*

View File

@ -1136,7 +1136,7 @@ xmlTextReaderGetSuccessor(xmlNodePtr cur) {
if (cur->next != NULL) return(cur->next) ; if (cur->next != NULL) return(cur->next) ;
do { do {
cur = cur->parent; cur = cur->parent;
if (cur == NULL) return(NULL); if (cur == NULL) break;
if (cur->next != NULL) return(cur->next); if (cur->next != NULL) return(cur->next);
} while (cur != NULL); } while (cur != NULL);
return(cur); return(cur);
@ -1469,11 +1469,11 @@ node_found:
return -1; return -1;
xmlXIncludeProcessNode(reader->xincctxt, reader->node); xmlXIncludeProcessNode(reader->xincctxt, reader->node);
} }
if (reader->node->type == XML_XINCLUDE_START) { if ((reader->node != NULL) && (reader->node->type == XML_XINCLUDE_START)) {
reader->in_xinclude++; reader->in_xinclude++;
goto get_next_node; goto get_next_node;
} }
if (reader->node->type == XML_XINCLUDE_END) { if ((reader->node != NULL) && (reader->node->type == XML_XINCLUDE_END)) {
reader->in_xinclude--; reader->in_xinclude--;
goto get_next_node; goto get_next_node;
} }

View File

@ -3010,6 +3010,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
* if we are working on a range like "AB{0,2}", where B is not present, * if we are working on a range like "AB{0,2}", where B is not present,
* we don't want to break. * we don't want to break.
*/ */
len = 1;
if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) { if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) {
/* /*
* if there is a transition, we must check if * if there is a transition, we must check if
@ -3038,6 +3039,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
int count; int count;
xmlRegCounterPtr counter; xmlRegCounterPtr counter;
if (exec->counts == NULL) {
exec->status = -1;
goto error;
}
/* /*
* A counted transition. * A counted transition.
*/ */
@ -3067,6 +3072,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
* before potentially saving and rollback * before potentially saving and rollback
*/ */
if (trans->counter >= 0) { if (trans->counter >= 0) {
if (exec->counts == NULL) {
exec->status = -1;
goto error;
}
#ifdef DEBUG_REGEXP_EXEC #ifdef DEBUG_REGEXP_EXEC
printf("Increasing count %d\n", trans->counter); printf("Increasing count %d\n", trans->counter);
#endif #endif
@ -3122,6 +3131,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
goto rollback; goto rollback;
} }
if (trans->counter >= 0) { if (trans->counter >= 0) {
if (exec->counts == NULL) {
exec->status = -1;
goto error;
}
#ifdef DEBUG_REGEXP_EXEC #ifdef DEBUG_REGEXP_EXEC
printf("Decreasing count %d\n", trans->counter); printf("Decreasing count %d\n", trans->counter);
#endif #endif
@ -3158,6 +3171,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
xmlFARegExecSave(exec); xmlFARegExecSave(exec);
} }
if (trans->counter >= 0) { if (trans->counter >= 0) {
if (exec->counts == NULL) {
exec->status = -1;
goto error;
}
#ifdef DEBUG_REGEXP_EXEC #ifdef DEBUG_REGEXP_EXEC
printf("Increasing count %d\n", trans->counter); printf("Increasing count %d\n", trans->counter);
#endif #endif
@ -3165,6 +3182,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
} }
if ((trans->count >= 0) && if ((trans->count >= 0) &&
(trans->count < REGEXP_ALL_COUNTER)) { (trans->count < REGEXP_ALL_COUNTER)) {
if (exec->counts == NULL) {
exec->status = -1;
goto error;
}
#ifdef DEBUG_REGEXP_EXEC #ifdef DEBUG_REGEXP_EXEC
printf("resetting count %d on transition\n", printf("resetting count %d on transition\n",
trans->count); trans->count);
@ -3200,6 +3221,7 @@ rollback:
progress: progress:
continue; continue;
} }
error:
if (exec->rollbacks != NULL) { if (exec->rollbacks != NULL) {
if (exec->counts != NULL) { if (exec->counts != NULL) {
int i; int i;
@ -3606,6 +3628,7 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
} }
if ((count >= counter->min) && if ((count >= counter->min) &&
(count < counter->max) && (count < counter->max) &&
(t->atom != NULL) &&
(xmlStrEqual(value, t->atom->valuep))) { (xmlStrEqual(value, t->atom->valuep))) {
ret = 1; ret = 1;
break; break;
@ -4035,15 +4058,16 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
/* this should not be reached but ... */ /* this should not be reached but ... */
TODO; TODO;
} else if (trans->counter >= 0) { } else if (trans->counter >= 0) {
xmlRegCounterPtr counter; xmlRegCounterPtr counter = NULL;
int count; int count;
if (err) if (err)
count = exec->errCounts[trans->counter]; count = exec->errCounts[trans->counter];
else else
count = exec->counts[trans->counter]; count = exec->counts[trans->counter];
counter = &exec->comp->counters[trans->counter]; if (exec->comp != NULL)
if (count < counter->max) { counter = &exec->comp->counters[trans->counter];
if ((counter == NULL) || (count < counter->max)) {
if (atom->neg) if (atom->neg)
values[nb++] = (xmlChar *) atom->valuep2; values[nb++] = (xmlChar *) atom->valuep2;
else else
@ -4711,6 +4735,7 @@ xmlFAParseCharRef(xmlRegParserCtxtPtr ctxt) {
((cur >= 'a') && (cur <= 'f')) || ((cur >= 'a') && (cur <= 'f')) ||
((cur >= 'A') && (cur <= 'F'))) { ((cur >= 'A') && (cur <= 'F'))) {
while (((cur >= '0') && (cur <= '9')) || while (((cur >= '0') && (cur <= '9')) ||
((cur >= 'a') && (cur <= 'f')) ||
((cur >= 'A') && (cur <= 'F'))) { ((cur >= 'A') && (cur <= 'F'))) {
if ((cur >= '0') && (cur <= '9')) if ((cur >= '0') && (cur <= '9'))
ret = ret * 16 + cur - '0'; ret = ret * 16 + cur - '0';
@ -5492,9 +5517,9 @@ xmlAutomataNewTransition2(xmlAutomataPtr am, xmlAutomataStatePtr from,
if ((am == NULL) || (from == NULL) || (token == NULL)) if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL); return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING); atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
atom->data = data;
if (atom == NULL) if (atom == NULL)
return(NULL); return(NULL);
atom->data = data;
if ((token2 == NULL) || (*token2 == 0)) { if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token); atom->valuep = xmlStrdup(token);
} else { } else {
@ -5805,10 +5830,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
} }
atom->data = data; atom->data = data;
atom->quant = XML_REGEXP_QUANT_ONCEONLY; atom->quant = XML_REGEXP_QUANT_ONCEONLY;
if (min == 0) atom->min = min;
atom->min = 1;
else
atom->min = min;
atom->max = max; atom->max = max;
/* /*
* associate a counter to the transition. * associate a counter to the transition.
@ -5867,10 +5889,7 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
atom->valuep = xmlStrdup(token); atom->valuep = xmlStrdup(token);
atom->data = data; atom->data = data;
atom->quant = XML_REGEXP_QUANT_ONCEONLY; atom->quant = XML_REGEXP_QUANT_ONCEONLY;
if (min == 0) atom->min = min;
atom->min = 1;
else
atom->min = min;
atom->max = max; atom->max = max;
/* /*
* associate a counter to the transition. * associate a counter to the transition.
@ -6621,7 +6640,9 @@ xmlExpNewAtom(xmlExpCtxtPtr ctxt, const xmlChar *name, int len) {
*/ */
xmlExpNodePtr xmlExpNodePtr
xmlExpNewOr(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) { xmlExpNewOr(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) {
if ((ctxt == NULL) || (left == NULL) || (right == NULL)) { if (ctxt == NULL)
return(NULL);
if ((left == NULL) || (right == NULL)) {
xmlExpFree(ctxt, left); xmlExpFree(ctxt, left);
xmlExpFree(ctxt, right); xmlExpFree(ctxt, right);
return(NULL); return(NULL);
@ -6644,7 +6665,9 @@ xmlExpNewOr(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) {
*/ */
xmlExpNodePtr xmlExpNodePtr
xmlExpNewSeq(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) { xmlExpNewSeq(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) {
if ((ctxt == NULL) || (left == NULL) || (right == NULL)) { if (ctxt == NULL)
return(NULL);
if ((left == NULL) || (right == NULL)) {
xmlExpFree(ctxt, left); xmlExpFree(ctxt, left);
xmlExpFree(ctxt, right); xmlExpFree(ctxt, right);
return(NULL); return(NULL);
@ -6668,7 +6691,9 @@ xmlExpNewSeq(xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right) {
*/ */
xmlExpNodePtr xmlExpNodePtr
xmlExpNewRange(xmlExpCtxtPtr ctxt, xmlExpNodePtr subset, int min, int max) { xmlExpNewRange(xmlExpCtxtPtr ctxt, xmlExpNodePtr subset, int min, int max) {
if ((ctxt == NULL) || (subset == NULL) || (min < 0) || (max < -1) || if (ctxt == NULL)
return(NULL);
if ((subset == NULL) || (min < 0) || (max < -1) ||
((max >= 0) && (min > max))) { ((max >= 0) && (min > max))) {
xmlExpFree(ctxt, subset); xmlExpFree(ctxt, subset);
return(NULL); return(NULL);

22
xpath.c
View File

@ -292,11 +292,12 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
static void static void
xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra) xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra)
{ {
ctxt->error = XPATH_MEMORY_ERROR;
if (ctxt == NULL) if (ctxt == NULL)
xmlXPathErrMemory(NULL, extra); xmlXPathErrMemory(NULL, extra);
else else {
ctxt->error = XPATH_MEMORY_ERROR;
xmlXPathErrMemory(ctxt->context, extra); xmlXPathErrMemory(ctxt->context, extra);
}
} }
/** /**
@ -1112,10 +1113,6 @@ xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
fprintf(output, shift); fprintf(output, shift);
if (comp == NULL) {
fprintf(output, "Compiled Expression is NULL\n");
return;
}
fprintf(output, "Compiled Expression : %d elements\n", fprintf(output, "Compiled Expression : %d elements\n",
comp->nbStep); comp->nbStep);
i = comp->last; i = comp->last;
@ -1452,9 +1449,11 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
/* Use scientific notation */ /* Use scientific notation */
integer_place = DBL_DIG + EXPONENT_DIGITS + 1; integer_place = DBL_DIG + EXPONENT_DIGITS + 1;
fraction_place = DBL_DIG - 1; fraction_place = DBL_DIG - 1;
snprintf(work, sizeof(work),"%*.*e", size = snprintf(work, sizeof(work),"%*.*e",
integer_place, fraction_place, number); integer_place, fraction_place, number);
after_fraction = strchr(work + DBL_DIG, 'e'); while ((size > 0) && (work[size] != 'e')) size--;
after_fraction = work + size;
} }
else { else {
/* Use regular notation */ /* Use regular notation */
@ -3507,7 +3506,8 @@ xmlXPathCastNumberToString (double val) {
} else { } else {
/* could be improved */ /* could be improved */
char buf[100]; char buf[100];
xmlXPathFormatNumber(val, buf, 100); xmlXPathFormatNumber(val, buf, 99);
buf[99] = 0;
ret = xmlStrdup((const xmlChar *) buf); ret = xmlStrdup((const xmlChar *) buf);
} }
} }
@ -5516,7 +5516,7 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
do { do {
cur = cur->parent; cur = cur->parent;
if (cur == NULL) return(NULL); if (cur == NULL) break;
if (cur == ctxt->context->node) return(NULL); if (cur == ctxt->context->node) return(NULL);
if (cur->next != NULL) { if (cur->next != NULL) {
cur = cur->next; cur = cur->next;
@ -5846,7 +5846,7 @@ xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (cur->next != NULL) return(cur->next) ; if (cur->next != NULL) return(cur->next) ;
do { do {
cur = cur->parent; cur = cur->parent;
if (cur == NULL) return(NULL); if (cur == NULL) break;
if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL); if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL);
if (cur->next != NULL) return(cur->next); if (cur->next != NULL) return(cur->next);
} while (cur != NULL); } while (cur != NULL);