Jump to content


Photo

BlendColor interger overflow


  • Please log in to reply
10 replies to this topic

#1 flavsouvou

flavsouvou

    Senior Member

  • Members
  • PipPip
  • 207 posts

Posted 26 June 2009 - 12:09 AM

I ve got a integer overflow on this line in function BlendColor in Nxshareddraw.pas line 101 :


Result := Integer(
((Cardinal(UpColor) and $FF00FF) * Cardinal(Amount) +
(Cardinal(DownColor) and $FF00FF) * Value) and $FF00FF00 +
((Cardinal(UpColor) and $00FF00) * Cardinal(Amount) +
(Cardinal(DownColor) and $00FF00) * Value) and $00FF0000) shr 8;


Play with the demo and click on the 2 buttons to open and close iForm2.


The pb occurs occasionnaly after clicking several times.


Attached Files



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 26 June 2009 - 05:48 PM

Hi flavsouvou,

Can you please send me a source of this demo project. It will help me to find a problem.

Thank you,

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 flavsouvou

flavsouvou

    Senior Member

  • Members
  • PipPip
  • 207 posts

Posted 26 June 2009 - 05:57 PM

see attached

Attached Files



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 26 June 2009 - 07:03 PM

QUOTE (flavsouvou @ Jun 26 2009, 04:57 PM) <{POST_SNAPBACK}>
see attached


Hi,

First, thank you for your demo,

For some reason, when I have delete components that I don't have, bug don't occur any more.

Can you please check attached exe file and try to reproduce bug.

Maybe you can send me a other demo without additional components to I test it.

Best regards

Attached Files


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 flavsouvou

flavsouvou

    Senior Member

  • Members
  • PipPip
  • 207 posts

Posted 26 June 2009 - 07:33 PM

I ve noticed the same behavior.

That s strange.

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 26 June 2009 - 07:55 PM

Hi,

Maybe some additional component made a problem.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 flavsouvou

flavsouvou

    Senior Member

  • Members
  • PipPip
  • 207 posts

Posted 27 June 2009 - 10:42 PM

when pgscrollbuttons is set to false, the problem is solved.
I think you ve got a pb in TnxpageControl...

#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 28 June 2009 - 12:06 AM

Hello,

It may be some problem with additional components. If you can somehow reproduce it without them this will be great.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 vhorky

vhorky
  • Members
  • 5 posts
  • Gender:Male
  • Location:Czech republic

Posted 07 April 2011 - 10:34 PM

Hi,
I have the same problem with fatal error "Integer overflow" in BlendColor method.
I have to change source code to:

class function TGraphicsProvider.BlendColor(Color1, Color2: TColor; Amount: Integer): TColor;
var
Value: Integer;
v,a,c1,c2 :Int64;
begin
Assert(Amount in [0..255]);
Value := Amount xor 255;
if Integer(Color1) < 0 then Color1 := GetSysColor(Color1 and $000000FF);
if Integer(Color2) < 0 then Color2 := GetSysColor(Color2 and $000000FF);

c1 := Color1;
c2 := Color2;
a := Amount;
v := Value;

Result := (((
((c1 and $FF00FF) * a +
(c2 and $FF00FF) * v) and $FF00FF00 +
((c1 and $00FF00) * a +
(c2 and $00FF00) * v) and $00FF0000) shr 8) and $FFFFFFFF);
end;

#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 08 April 2011 - 12:10 AM

Hello,

Thank you Vhorky. I will test it tomorrow with your fix.

Problem is since I never receive this problem, to be able to solve it.

Thank you again

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 user22

user22
  • Members
  • 192 posts
  • Gender:Male
  • Location:Linz / Austria

Posted 09 April 2011 - 10:33 PM

Hi,

i think this is the same problem i reported some month ago:
http://www.bergsoft....?showtopic=3590

bye,
Helmut




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users