Page 1 of 1
gscintilla giving error "[ERROR] Overflow in a dynamically allocated memory block.
Posted: Sun Sep 03, 2023 1:54 am
by TRS-Eric
The error is occurring around line 309:
Code: Select all
caretPos = ScintillaSendMessage(*this\id, #SCI_GETCURLINE, numUtf8Bytes+1, *utf8Buffer)
I removed the +1 on numUtf8Bytes and that fixed it, but I'm not entirely sure what this does, so I'm worried about problems later.
Any ideas on how to fix? The error occurs when editing UTF8 data, possibly corrupt? The data loaded is UTF8-bom according to Notepad++
See screenshot:
https://imgur.com/a/bHj1aOL

Re: gscintilla giving error "[ERROR] Overflow in a dynamically allocated memory block.
Posted: Sun Sep 03, 2023 7:32 am
by PeDe
Scintilla can return zero at line 301. For example, if the cursor is in the last line without text. Line 309 then passes a pointer to an empty memory location. This should trigger the error. So you should check the return of line 301 for zero, and not assume that there is always a length greater than zero.
Edit: Line 302 also checks wrong, minus one also gives True, only zero gives False.
Edit2: Your error probably has another cause. You can't allocate memory with zero bytes, PB will give an error. So the return of line 301 will not be 0 or -1.
But this is only assumed, I only read your code.
Peter
Re: gscintilla giving error "[ERROR] Overflow in a dynamically allocated memory block.
Posted: Sun Sep 03, 2023 12:25 pm
by spikey
Try changing line 302 to read:
If Peter is right that should fix it.
Re: gscintilla giving error "[ERROR] Overflow in a dynamically allocated memory block.
Posted: Mon Sep 04, 2023 12:13 am
by TassyJim
I had the same problem when I changed to PB603
I made the same change and in a few other places as well
Code: Select all
numUtf8Bytes = ScintillaSendMessage(*this\id, #SCI_GETCURLINE, 0, 0) ;- 1 ;Includes the null, hence the -1. removed to suit pb603
If numUtf8Bytes
bufferPtr = AllocateMemory(numUtf8Bytes+2) ; added an extra byte to suit pb603
If bufferPtr
If *this\state & #GOSCI_LEXERSTATE_ENABLECALLTIPS
blnProceedWithCallTip = #True
EndIf
*utf8Buffer = bufferPtr
caretPos = ScintillaSendMessage(*this\id, #SCI_GETCURLINE, numUtf8Bytes, *utf8Buffer) ; +1 removed to suit pb603
I think something changed in the latest scintilla update.
My reasoning is, if in doubt, include a few a extra bytes 'just in case'
I ended up searching my full project and added extra bytes to all likely AllocateMemory functions.
It seems to have worked.
Jim