Re: [xml] Runtime exception occurs on mod operations when second arg is zero



On Sun, Aug 26, 2001 at 12:37:55PM -0500, Chris_Poblete Dell com wrote:
VERSIONS: libxml2-2.4.3
          libxslt-1.0.3

PROBLEM:
The tag <xsl:when test="($row mod $col) = 0"> causes runtime exception
when $col happens to be zero.  It would be correct to handle this case
by exiting the program gracefully (and perhaps show error message on debug).


PROPOSED RESOLUTION:
xpath.c:xmlXPathModValues(4425)
------------------------------------------------------------
<     ctxt->value->floatval = arg1 % arg2;
----------
    // When arg2 is zero at runtime, it will evaluate to 'divide by
zero'
    // and will cause runtime exception.  Instead check to allow
graceful exit.
    if (arg2 == 0)
            ctxt->value->floatval = xmlXPathNAN;
    else
            ctxt->value->floatval = arg1 % arg2;
------------------------------------------------------------

  Looks fine, applied,

    thanks,

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]