Hello all,
using DirectFB 1.4.15 and DirectFB-examples-1.2.0 from buildroot-2011.11
on an ARM926EJS-based platform "df_dok --draw-string" is crashing with a
"Floating point exception" for me.
The offending code can be found in draw_string() and
draw_string_blend(). For my system, "SW" (screen width) is 320 and by
lucky chance "stringwidth" is 320 as well.
The calculation "myrand() % (SW-stringwidth)" then produces the floating
point exception, because (SW-stringwidth) is 0 ...
The attached patch for DirectFB-examples-1.2.0 changes the code so that
it checks if (SW-stringwidth) is > 0 and if not, uses 0 instead.
The bug is present in the Git version of df_dok as well.
CU
MIchael.
diff -urwBpd directfb-examples-1.2.0.orig/src/df_dok.c
directfb-examples-1.2.0/src/df_dok.c
--- directfb-examples-1.2.0.orig/src/df_dok.c 2008-05-20 10:42:08.000000000
+0200
+++ directfb-examples-1.2.0/src/df_dok.c 2011-12-02 19:42:54.557383269
+0100
@@ -604,7 +604,7 @@ static unsigned long long draw_string( l
myrand()&0xFF, myrand()&0xFF, myrand()&0xFF, 0xFF );
dest->DrawString( dest,
"DirectX is dead, this is DirectFB!!!", -1,
- myrand() % (SW-stringwidth),
+ SW-stringwidth > 0 ? myrand() % (SW-stringwidth) :
0,
myrand() % (SH-bench_fontheight),
DSTF_TOPLEFT );
}
@@ -629,7 +629,7 @@ static unsigned long long draw_string_bl
myrand()%0x64 );
dest->DrawString( dest,
"DirectX is dead, this is DirectFB!!!", -1,
- myrand() % (SW-stringwidth),
+ SW-stringwidth > 0 ? myrand() % (SW-stringwidth) :
0,
myrand() % (SH-bench_fontheight),
DSTF_TOPLEFT );
}
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev