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



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;
------------------------------------------------------------



_______________________________
Chris Poblete
Dell © Enterprise Servers Group






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