[ScintillaNET] A Modification Event Handler Bug

  • From: Greg Dietsche <Gregory.Dietsche@xxxxxxx>
  • To: ScintillaNET <ScintillaNET@xxxxxxxxxxxxx>
  • Date: Wed, 23 Jun 2004 22:55:28 -0500

Sorry about the double post before.... I thought the mailing list had blocked my attachment.

I just started to use the sc-net Modified event handler, and once in a while, it throws an error telling me that the unmanaged code has overflowed a buffer, and possibly corrupted some memory.

I looked into the problem, and it appears to lie within code from ScintillaControl.cs:

Specifically, I don't think all of the modification events supply a valid string pointer. Some of them *appear* (I do not know this for sure) to pass a pointer that points to garbage instead. After watching this for a bit, I noticed that the 0x400 (beforeinsert) event mask is the only one that seems to have a (valid) string attached to it!? If this is the case, then there needs to be some code added to test if that bit is indeed set, and then act accordingly.... ie:

if(( scn.modificationType & (uint)Enums.ModificationFlags.beforedelete )>0 )
    Modified( this, scn.position, scn.modificationType, System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text), scn.length, scn.linesAdded, scn.line, scn.foldLevelNow,scn.foldLevelPrev );
else
    Modified( this, scn.position, scn.modificationType, null, scn.length, scn.linesAdded, scn.line, scn.foldLevelNow,scn.foldLevelPrev );

this should prevent that crash from happening, but it doesn't gurantee that the other variables are valid of course...

--

Regards,
Greg Dietsche     http://www.gregd.org/
GForce Programming:   http://calc.gregd.org
Detached Solutions:      http://www.detachedsolutions.com

-------------------------------------------------------------------------- ScintillaNET Mailing List: ScintillaNET@xxxxxxxxxxxxx To unsubscribe: Send an email to scintillanet-request@xxxxxxxxxxxxx and put "unsubscribe" (without the quotes) in the Subject line. Web Page: http://tinyurl.com/yvoh2

Other related posts: