GNOME Bugzilla – Bug 738053
Fixing Null Pointers.
Last modified: 2014-10-08 01:53:30 UTC
Created attachment 287904 [details] [review] Fixing Null Pointers. At many places in xpointer.c Null check is missing which is dereferenced at later places. Please apply the patch. Also below code: 1817 newset = xmlXPtrLocationSetCreate(NULL); 1818 if (newset == NULL) { 1819 xmlXPathFreeObject(obj); 1820 XP_ERROR(XPATH_MEMORY_ERROR); 1821 } is already there, so similar checks added at other places.
Okay all looks right except a couple of place where there was a space and tab mixup for indentation, applied and commited to git, thanks ! Daniel
Thanks for applying the Patch. I have a question regarding valuePop API, It is used everywhere without checking return value against NULL. For E.g: xpointer.c 1805 obj = valuePop(ctxt); 1806 if (obj->type == XPATH_NODESET) { As we see below, this API can return NULL. Do NULL check required. If it is required, I can submit a patch. But changes would be many. Please let me know. xmlXPathObjectPtr valuePop(xmlXPathParserContextPtr ctxt) { xmlXPathObjectPtr ret; if ((ctxt == NULL) || (ctxt->valueNr <= 0)) return (NULL); if (ctxt->valueNr <= ctxt->valueFrame) { xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR); return (NULL); } ctxt->valueNr--; if (ctxt->valueNr > 0) ctxt->value = ctxt->valueTab[ctxt->valueNr - 1]; else ctxt->value = NULL; ret = ctxt->valueTab[ctxt->valueNr]; ctxt->valueTab[ctxt->valueNr] = NULL; return (ret); }
Yes it can return NULL for example if there is no more objects on the stack, I would focus more on xpath.c than xpointer.c as its use is far more common. thanks, Daniel