GuiTreeViewCtrl text issue
by Phil Carlisle · in Torque Game Engine Advanced · 01/12/2007 (4:31 am) · 4 replies
I had a crash the other night, when tracing it, I came to
GuiTreeViewCtrl::InsertItem (I think its that, dont have the code in front of me).
In there, it has a couple of potentially nasty bugs.
Basically, it does an allocation, then passes that allocation to .setText();
If you lookat it, basically, it gets the length of the text to insert, it allocates a buffer of that size, then it passes that newly allocated buffer into set text.
Problems:
1) Buffer is not initialised
2) Text length isnt size checked for validity
3) The .setText method actually sizes the control to the largest text size. To do this, it iterates each text item and does a call to get the pixel size for each line of text..
Anyone spot the problem?
Yesss! it passes an UNINITIALISED buffer, which then gets its size checked!
So slapped wrists for whoever wrote that code.. :)
Fixes? I'll let you figure those as an exercise. (Besides, I dont have the code in front of me).
GuiTreeViewCtrl::InsertItem (I think its that, dont have the code in front of me).
In there, it has a couple of potentially nasty bugs.
Basically, it does an allocation, then passes that allocation to .setText();
If you lookat it, basically, it gets the length of the text to insert, it allocates a buffer of that size, then it passes that newly allocated buffer into set text.
Problems:
1) Buffer is not initialised
2) Text length isnt size checked for validity
3) The .setText method actually sizes the control to the largest text size. To do this, it iterates each text item and does a call to get the pixel size for each line of text..
Anyone spot the problem?
Yesss! it passes an UNINITIALISED buffer, which then gets its size checked!
So slapped wrists for whoever wrote that code.. :)
Fixes? I'll let you figure those as an exercise. (Besides, I dont have the code in front of me).
About the author
Torque Owner Brian Ramage
Default Studio Name