Ben Combee wrote:
There's no patch, but I'd be glad to consider one that you created... you've got all the code there in front of you. :)

On 2/16/07, *Sakur* < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:



    Ben Combee wrote:
    On 2/15/07, *Sakur* < [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>> wrote:

        Hi,All:
            Recently,when I tested my directfb application (through
        some special test engine),I encountered a assert fail located
        in dfb_gfxcard_blit(gfxcard.c)-->>>D_ASSERT( rect->x <
        state->source->width )
            In my test program,a source rectangle
        (x:INT_MAX,y:INT_MAX,w:INT_MAX,h:INT_MAX) was passed into
IDirectFBSurface->Blit function,then,the assert error crashed the program.Theoretically, this rectangle should
        never be intersected with any surface area. But it passed the
        intersect check in IDirectFBSurface_Blit ,(function
        *dfb_rectangle_intersect* return true), therefore caused the
        assert in dfb_gfx_blit. The reason why it could pass is that
        INT_MAX+INT_MAX = -2 (see dfb_rectangle_intersect
        implementation). Am I missed something that this issue is
        already known or anyone help me confirm this? Thanks


    This sounds like a valid error... the numbers usually handled in
    coordinate spaces in directfb are so small that this hadn't been
    seen before.

    The problem is that the rectangle is invalid because it can't be
    converted into a DFBRegion -- while the top-left corner is in the
    valid coordinate space (INT_MAX, INT_MAX), the bottom-right
    corner is outside that space (actually, any size rectangle other
    than 0,0 would be invalid here).



    Hi,Ben
        Yeah,actually ,it is a weird case for this test that results a
    valid fail!
        However,as I mentioned in the mail ==> dfb_rectangle_intersect
    return TRUE,I may expect this would return FALSE,so it couldn't
    crash the application at asserting failure. Any patch necessary to
    avoid this rare problem (let dfb_rectangle_intersect return FALSE)?

    Cheers
    Sakur


Hi,Ben:
Sorry for the late. I just returned from the Chinese Spring Festival :)(Chinese New Year). Considering this patch is not necessary for most of normal developers, Here's the patch(Considering this patch is not necessary to most of the developers,I'll not commit to the main trunk):


--- DirectFB-1.0.0-rc4/src/misc/util.c 2007-02-26 11:02:34.000000000 +0000 +++ DirectFB-1.0.0-rc4/src/misc/util.c.old 2007-02-26 11:01:09.000000000 +0000
@@ -7,7 +7,7 @@
   Written by Denis Oliver Kropp <[EMAIL PROTECTED]>,
              Andreas Hundt <[EMAIL PROTECTED]>,
              Sven Neumann <[EMAIL PROTECTED]> and
-              Ville Syrj??<[EMAIL PROTECTED]>.
+              Ville Syrj??<[EMAIL PROTECTED]>.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,6 @@
#include <misc/util.h>


-
bool
dfb_region_intersect( DFBRegion *region,
                      int x1, int y1, int x2, int y2 )
@@ -107,10 +106,10 @@
         region->y1 > y2)
          return false;

-     if (region->y1 < rect->y)
     if (region->x1 < rect->x)
          region->x1 = rect->x;

+     if (region->y1 < rect->y)
          region->y1 = rect->y;

     if (region->x2 > x2)
@@ -189,11 +188,10 @@
     }

     /* adjust size */
- //FIXME: handling INT_MAX cases :rectangle->x + rectangle->w INT overflow - if (region->x2 < rectangle->x + rectangle->w - 1||(rectangle->x + rectangle->w)<0)
+     if (region->x2 < rectangle->x + rectangle->w - 1)
        rectangle->w = region->x2 - rectangle->x + 1;

- if (region->y2 < rectangle->y + rectangle->h - 1||(rectangle->y + rectangle->h)<0)
+     if (region->y2 < rectangle->y + rectangle->h - 1)
        rectangle->h = region->y2 - rectangle->y + 1;

     /* set size to zero if there's no intersection */
@@ -223,11 +221,10 @@
     }

     /* adjust size */
- //FIXME: handling INT_MAX cases :rectangle->x + rectangle->w INT overflow - if (region->x2 < rectangle->x + rectangle->w - 1||(rectangle->x + rectangle->w)<0)
+     if (region->x2 < rectangle->x + rectangle->w - 1)
        rectangle->w = region->x2 - rectangle->x + 1;

- if (region->y2 < rectangle->y + rectangle->h - 1||(rectangle->y + rectangle->h)<0)
+     if (region->y2 < rectangle->y + rectangle->h - 1)
        rectangle->h = region->y2 - rectangle->y + 1;

     /* set size to zero if there's no intersection */
@@ -246,6 +243,7 @@
{
     DFBRegion region = { clip->x, clip->y,
                          clip->x + clip->w - 1, clip->y + clip->h - 1 };
+
     /* adjust position */
     if (region.x1 > rectangle->x) {
          rectangle->w -= region.x1 - rectangle->x;
@@ -258,15 +256,14 @@
     }

     /* adjust size */
- //FIXME: handling INT_MAX cases :rectangle->x + rectangle->w INT overflow - if (region.x2 < (rectangle->x + rectangle->w - 1)||(rectangle->x+rectangle->w)<0)
+     if (region.x2 < rectangle->x + rectangle->w - 1)
          rectangle->w = region.x2 - rectangle->x + 1;

- if (region.y2 < (rectangle->y + rectangle->h - 1)||(rectangle->y+rectangle->h)<0)
+     if (region.y2 < rectangle->y + rectangle->h - 1)
          rectangle->h = region.y2 - rectangle->y + 1;

     /* set size to zero if there's no intersection */
-     if ((rectangle->w <= 0) || (rectangle->h <= 0)) {
+     if (rectangle->w <= 0 || rectangle->h <= 0) {
          rectangle->w = 0;
          rectangle->h = 0;

Cheers
Sakur


_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to