<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>38680</bug_id>
          
          <creation_ts>2010-05-06 13:20:12 -0700</creation_ts>
          <short_desc>FloatRect::enclosingIntRect performs unsafe type conversion float -&gt; int</short_desc>
          <delta_ts>2010-05-07 15:15:34 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>38684</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="W. James MacLean">wjmaclean</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>221912</commentid>
    <comment_count>0</comment_count>
    <who name="W. James MacLean">wjmaclean</who>
    <bug_when>2010-05-06 13:20:12 -0700</bug_when>
    <thetext>Steps to Reproduce:

Render the attached SVG file (mask-excessive-malloc.svg, from the existing layout tests directory)

Actual output: dumping the render tree gives

layer at (0,0) size 800x600
  RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
  RenderSVGRoot {svg} at (0,0) size 800x600
    RenderSVGResourceMasker {mask} [id=&quot;mask&quot;] [maskUnits=objectBoundingBox] [maskContentUnits=userSpaceOnUse]
      RenderPath {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FFFFFF]}] [data=&quot;M0.00,0.00 L2147483648.00,0.00 L2147483648.00,2147483648.00 L0.00,2147483648.00 Z&quot;]
    RenderPath {path} at (200,200) size 100x200 [fill={[type=SOLID] [color=#0000FF]}] [data=&quot;M200.00,200.00 L300.00,200.00 L300.00,400.00 L200.00,400.00 Z&quot;]
      [masker=&quot;mask&quot;] RenderSVGResourceMasker {mask} at (190,180) size 214748364800.00x429496729600.00

Expected output: the render tree should look like (note size of first RenderPath object):


layer at (0,0) size 800x600
  RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
  RenderSVGRoot {svg} at (0,0) size 800x600
    RenderSVGResourceMasker {mask} [id=&quot;mask&quot;] [maskUnits=objectBoundingBox] [maskContentUnits=userSpaceOnUse]
      RenderPath {rect} at (0,0) size 800x600 [fill={[type=SOLID] [color=#FFFFFF]}] [data=&quot;M0.00,0.00 L2147483648.00,0.00 L2147483648.00,2147483648.00 L0.00,2147483648.00 Z&quot;]
    RenderPath {path} at (200,200) size 100x200 [fill={[type=SOLID] [color=#0000FF]}] [data=&quot;M200.00,200.00 L300.00,200.00 L300.00,400.00 L200.00,400.00 Z&quot;]
      [masker=&quot;mask&quot;] RenderSVGResourceMasker {mas


Additional information:

The underlying cause appears to be an unsafe float-&gt; int conversion in FloatRect::enclosingIntRect, where static_cast&lt;int&gt; is used on a float outside the range representable by int.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>222593</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-05-07 13:39:34 -0700</bug_when>
    <thetext>The incorrect result is what is currently checked in as an expected result. Why is it incorrect?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>222644</commentid>
    <comment_count>2</comment_count>
    <who name="W. James MacLean">wjmaclean</who>
    <bug_when>2010-05-07 15:03:03 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; The incorrect result is what is currently checked in as an expected result. Why
&gt; is it incorrect?

I assume we&apos;re both looking at

http://trac.webkit.org/browser/trunk/LayoutTests/platform/mac/svg/custom/mask-excessive-malloc-expected.txt

If you modify mask-excessive-malloc.svg so the rect has dimensions in the range of int, and dump the results render tree, you will find the size of the RenderPath (line 6) is 800x600, not 0x0. I.e. it clips to the size of the view port. If you fix the float -&gt; int conversions so that values greater than the max int 2147483647 are clipped to 2147483647 (which is one reasonable approach), then the size will be computed as 800x600. The 0x0 size seems to occur when very large positive floats get erroneously converted to -2147483648, which gets clipped to 0 for lengths such as height and width.

TI am going to request this bug be deleted, as it seems to have been created twice (the more up-to-date version being 38684).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>222655</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-05-07 15:15:34 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 38684 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>