+Fri Mar 10 12:49:18 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+ * libexslt/crypto.c libexslt/date.c libexslt/saxon.c
+ libxslt/attributes.c libxslt/imports.c libxslt/pattern.c
+ libxslt/preproc.c libxslt/transform.c libxslt/variables.c
+ libxslt/xslt.c libxslt/xsltutils.c: various assorted small cleanups
+ based on the Coverity reports
+
Wed Feb 22 16:09:10 CET 2006 Daniel Veillard <daniel@veillard.com>
* python/types.c: Nic Ferrier found debug statement left in the
http://cvs.gnome.org/viewcvs/libxslt/
code base.Those are the public releases made:
1.1.15: Sep 04 2005:
- - build fixes: Windows build cleanups and updates (Igor Zlatkovic), remove
- jhbuild warnings
- - bug fixes: negative number formatting (William Brack), number formatting
- per mille definition (William Brack), XInclude default values (William),
- text copy bugs (William), bug related to xmlXPathContext size, reuse
- libxml2 memory management for text nodes, dictionnary text bug, forbid
- variables in match (needs libxml2-2.6.21)
- - improvements: EXSLT dyn:map (Mark Vakoc),
-
+ - build fixes: Windows build cleanups and updates (Igor Zlatkovic),
+ remove jhbuild warnings
+ - bug fixes: negative number formatting (William Brack), number
+ formatting per mille definition (William Brack), XInclude default values
+ (William), text copy bugs (William), bug related to xmlXPathContext size,
+ reuse libxml2 memory management for text nodes, dictionnary text bug,
+ forbid variables in match (needs libxml2-2.6.21)
+ - improvements: EXSLT dyn:map (Mark Vakoc),
- documentation: EXSLT date and time functions namespace in man (Jonathan
- Wakely)
+ Wakely)
1.1.14: Apr 02 2005:
- bug fixes: text node on stylesheet document without a dictionary
- (William Brack), more checking of XSLT syntax, calling xsltInit() multiple
- times, mode values interning raised by Mark Vakoc, bug in pattern
- matching with ancestors, bug in patterna matching with cascading select,
- xinclude and document() problem, build outside of source tree (Mike
- Castle)
+ (William Brack), more checking of XSLT syntax, calling xsltInit()
+ multiple times, mode values interning raised by Mark Vakoc, bug in
+ pattern matching with ancestors, bug in patterna matching with cascading
+ select, xinclude and document() problem, build outside of source tree
+ (Mike Castle)
- improvement: added a --nodict mode to xsltproc to check problems for
- docuemtns without dictionnaries
-
+ docuemtns without dictionnaries
1.1.13: Mar 13 2005:
- build fixes: 64bits cleanup (William Brack), python 2.4 test (William),
- LIBXSLT_VERSION_EXTRA on Windows (William), Windows makefiles fixes
- (Joel Reed), libgcrypt-devel requires for RPM spec.
-
+ LIBXSLT_VERSION_EXTRA on Windows (William), Windows makefiles fixes (Joel
+ Reed), libgcrypt-devel requires for RPM spec.
- bug fixes: exslt day-of-week-in-month (Sal Paradise), xsl:call-template
- should not change the current template rule (William Brack), evaluation
- of global variables (William Brack), RVT's in XPath predicates (William),
- namespace URI on template names (Mark Vakoc), stat() for Windows patch
- (Aleksey Gurtovoy), pattern expression fixes (William Brack), out of
- memory detection misses (William), parserOptions propagation (William),
- exclude-result-prefixes fix (William), // patten fix (William).
-
- - extensions: module support (Joel Reed), dictionnary based speedups
- trying to get rid of xmlStrEqual as much as possible.
-
+ should not change the current template rule (William Brack), evaluation
+ of global variables (William Brack), RVT's in XPath predicates (William),
+ namespace URI on template names (Mark Vakoc), stat() for Windows patch
+ (Aleksey Gurtovoy), pattern expression fixes (William Brack), out of
+ memory detection misses (William), parserOptions propagation (William),
+ exclude-result-prefixes fix (William), // patten fix (William).
+ - extensions: module support (Joel Reed), dictionnary based speedups
+ trying to get rid of xmlStrEqual as much as possible.
- documentation: added Wiki (Joel Reed)
-
1.1.12: Oct 29 2004:
- build fixes: warnings removal (William).
- bug fixes: attribute document pointer fix (Mark Vakoc), exslt date
/* encrypt it */
bin_len = str_len;
bin = xmlStrdup (str);
+ if (bin == NULL) {
+ xmlXPathReturnEmptyString (ctxt);
+ goto done;
+ }
PLATFORM_RC4_ENCRYPT (ctxt, padkey, str, str_len, bin, bin_len);
/* encode it */
hex_len = str_len * 2 + 1;
hex = xmlMallocAtomic (hex_len);
+ if (hex == NULL) {
+ xmlXPathReturnEmptyString (ctxt);
+ goto done;
+ }
exsltCryptoBin2Hex (bin, str_len, hex, hex_len);
xmlXPathReturnString (ctxt, hex);
+done:
if (key != NULL)
xmlFree (key);
if (str != NULL)
static int
_exsltDateParseTimeZone (exsltDateValDatePtr dt, const xmlChar **str)
{
- const xmlChar *cur = *str;
+ const xmlChar *cur;
int ret = 0;
if (str == NULL)
return -1;
-
+ cur = *str;
switch (*cur) {
case 0:
dt->tz_flag = 0;
long tyr = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1, 1, 13);
if (tyr == 0)
tyr--;
+ /*
+ * Coverity detected an overrun in daysInMonth
+ * of size 12 at position 12 with index variable "((r)->mon - 1)"
+ */
+ if (tmon < 0)
+ tmon = 0;
+ if (tmon > 12)
+ tmon = 12;
tempdays += MAX_DAYINMONTH(tyr, tmon);
carry = -1;
} else if (tempdays > (long)MAX_DAYINMONTH(r->year, r->mon)) {
if ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewFloat(-1));
+ return;
}
cur = nodelist->nodeTab[0];
for (i = 1;i < nodelist->nodeNr;i++) {
const xmlChar *URL = NULL;
- if (ctxt->insert == NULL)
- return;
- if (comp == NULL) {
+ if ((comp == NULL) || (ctxt == NULL)) {
xsltTransformError(ctxt, NULL, inst,
"xsl:attribute : compilation failed\n");
return;
}
+ if (ctxt->insert == NULL)
+ return;
- if ((ctxt == NULL) || (node == NULL) || (inst == NULL)
- || (comp == NULL))
+ if ((node == NULL) || (inst == NULL) || (comp == NULL))
return;
if (!comp->has_name) {
return;
return(cur->next) ;
do {
cur = cur->parent;
- if (cur == NULL) return(NULL);
+ if (cur == NULL) break;
if (cur->next != NULL) return(cur->next);
} while (cur != NULL);
return(cur);
continue;
}
while (node != NULL) {
- if (node == NULL)
- goto rollback;
if ((node->type == XML_ELEMENT_NODE) &&
(step->value[0] == node->name[0]) &&
(xmlStrEqual(step->value, node->name))) {
xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
xsltStylePreCompPtr cur;
+ if (style == NULL)
+ return(NULL);
+
cur = (xsltStylePreCompPtr) xmlMalloc(sizeof(xsltStylePreComp));
if (cur == NULL) {
xsltTransformError(NULL, style, NULL,
"xsltNewStylePreComp : malloc failed\n");
- if (style != NULL) style->errors++;
+ style->errors++;
return(NULL);
}
memset(cur, 0, sizeof(xsltStylePreComp));
if (cur->func == NULL) {
xsltTransformError(NULL, style, NULL,
"xsltNewStylePreComp : no function for type %d\n", type);
- if (style != NULL) style->errors++;
+ style->errors++;
}
}
cur->next = style->preComps;
ctxt->lasttuse = len;
}
if (copy != NULL) {
- copy->doc = target->doc;
- if (target != NULL)
+ if (target != NULL) {
+ copy->doc = target->doc;
xmlAddChild(target, copy);
+ }
} else {
xsltTransformError(ctxt, NULL, target,
"xsltCopyText: text copy failed\n");
xmlNodePtr insert) {
xmlNodePtr copy;
- if (node->type == XML_DTD_NODE)
+ if ((node->type == XML_DTD_NODE) || (insert == NULL))
return(NULL);
if ((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE))
(node->type == XML_ATTRIBUTE_NODE)) {
if (node->ns != NULL) {
copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy);
- } else if ((insert != NULL) && (insert->type == XML_ELEMENT_NODE) &&
- (insert->ns != NULL)) {
+ } else if ((insert->type == XML_ELEMENT_NODE) &&
+ (insert->ns != NULL)) {
xmlNsPtr defaultNs;
defaultNs = xmlSearchNs(insert->doc, insert, NULL);
#endif
long start = 0;
+ if (ctxt == NULL) return;
+
#ifdef WITH_DEBUGGER
if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
if (templ) {
}
#endif
- if ((ctxt == NULL) || (list == NULL))
+ if (list == NULL)
return;
CHECK_STOPPED;
void
xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr inst, xsltStylePreCompPtr comp ATTRIBUTE_UNUSED) {
- xmlChar *prop = NULL;
xmlXPathObjectPtr res = NULL;
xmlNodePtr replacement, when;
int doit = 1;
NULL, NULL, 0);
goto done;
}
- if (prop != NULL)
- xmlFree(prop);
- prop = NULL;
if (res != NULL)
xmlXPathFreeObject(res);
res = NULL;
done:
error:
- if (prop != NULL)
- xmlFree(prop);
if (res != NULL)
xmlXPathFreeObject(res);
}
xmlNodePtr replacement;
xmlNodeSetPtr list = NULL, oldList;
int i, oldProximityPosition, oldContextSize;
- xmlNodePtr oldNode = ctxt->node;
+ xmlNodePtr oldNode;
int nbsorts = 0;
xmlNodePtr sorts[XSLT_MAX_SORT];
xmlDocPtr oldXDocPtr;
"xsl:for-each : compilation failed\n");
return;
}
+ oldNode = ctxt->node;
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
if ((res != NULL) && (ctxt != NULL) && (output != NULL)) {
int ret;
- ret = xsltCheckWrite(userCtxt->sec, userCtxt, (const xmlChar *) output);
+ ret = xsltCheckWrite(ctxt->sec, ctxt, (const xmlChar *) output);
if (ret == 0) {
xsltTransformError(ctxt, NULL, NULL,
"xsltApplyStylesheet: forbidden to save to %s\n",
if ((precomp == NULL) || (precomp->comp == NULL))
xmlXPathFreeCompExpr(comp);
if (result == NULL) {
- xsltTransformError(ctxt, NULL, precomp->inst,
- "Evaluating variable %s failed\n", elem->name);
+ if (precomp == NULL)
+ xsltTransformError(ctxt, NULL, NULL,
+ "Evaluating variable %s failed\n", elem->name);
+ else
+ xsltTransformError(ctxt, NULL, precomp->inst,
+ "Evaluating variable %s failed\n", elem->name);
ctxt->state = XSLT_STATE_STOPPED;
#ifdef WITH_XSLT_DEBUG_VARIABLE
#ifdef LIBXML_DEBUG_ENABLED
if ((precomp == NULL) || (precomp->comp == NULL))
xmlXPathFreeCompExpr(comp);
if (result == NULL) {
- xsltTransformError(ctxt, NULL, precomp->inst,
- "Evaluating global variable %s failed\n", elem->name);
+ if (precomp == NULL)
+ xsltTransformError(ctxt, NULL, NULL,
+ "Evaluating global variable %s failed\n", elem->name);
+ else
+ xsltTransformError(ctxt, NULL, precomp->inst,
+ "Evaluating global variable %s failed\n", elem->name);
ctxt->state = XSLT_STATE_STOPPED;
#ifdef WITH_XSLT_DEBUG_VARIABLE
#ifdef LIBXML_DEBUG_ENABLED
elem = xsltNewStackElem();
if (elem != NULL) {
elem->name = name;
- if (value != NULL)
- elem->select = xmlDictLookup(ctxt->dict, value, -1);
- else
- elem->select = NULL;
- if (href)
+ elem->select = xmlDictLookup(ctxt->dict, value, -1);
+ if (href != NULL)
elem->nameURI = xmlDictLookup(ctxt->dict, href, -1);
elem->tree = NULL;
elem->computed = 1;
xmlNodePtr delete;
int internalize = 0;
- if ((style != NULL) && (cur != NULL) && (cur->doc != NULL) &&
- (style->dict != NULL) && (cur->doc->dict == style->dict))
+ if ((style == NULL) || (cur == NULL))
+ return;
+
+ if ((cur->doc != NULL) && (style->dict != NULL) &&
+ (cur->doc->dict == style->dict))
internalize = 1;
else
style->internalized = 0;
xmlNodePtr cur;
const xmlChar *URI;
+ if (style == NULL)
+ return;
/*
* TODO: basically if the stylesheet uses the same prefix for different
* patterns, well they may be in problem, hopefully they will get
if (style->nsHash == NULL) {
xsltTransformError(NULL, style, cur,
"xsltGatherNamespaces: failed to create hash table\n");
- if (style != NULL) style->errors++;
+ style->errors++;
return;
}
}
if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
xsltTransformError(NULL, style, cur,
"Namespaces prefix %s used for multiple namespaces\n",ns->prefix);
- if (style != NULL) style->warnings++;
+ style->warnings++;
} else if (URI == NULL) {
xmlHashUpdateEntry(style->nsHash, ns->prefix,
(void *) ns->href, (xmlHashDeallocator)xmlFree);
(const xmlChar *)"no")){
xsltTransformError(NULL, style, cur,
"xsl:text: disable-output-escaping allows only yes or no\n");
- if (style != NULL) style->warnings++;
+ style->warnings++;
}
xmlFree(prop);
(text->type != XML_CDATA_SECTION_NODE)) {
xsltTransformError(NULL, style, cur,
"xsltParseTemplateContent: xslt:text content problem\n");
- if (style != NULL) style->errors++;
+ style->errors++;
break;
}
if ((noesc) && (text->type != XML_CDATA_SECTION_NODE))
* replace xsl:text by the list of childs
*/
if (text == NULL) {
- int internalize = 0;
- if ((style != NULL) && (text != NULL) &&
- (text->doc != NULL) && (style->dict != NULL) &&
- (text->doc->dict == style->dict))
- internalize = 1;
- else
- style->internalized = 0;
-
text = cur->children;
while (text != NULL) {
if ((text->content != NULL) &&
return(c);
error:
- *len = 0;
+ if (len != NULL)
+ *len = 0;
return(-1);
}