4.20 AllocateMemory and invalid memory access
Posted: Tue May 27, 2008 10:22 pm
I'm working on a IDE project using Scintilla
The following code report very often a Invalid Memory Access on the AllocateMemory function.
I also noticed:
- Same with 4.10
- No problem without the debugger
Any suggestion ?
Many thanks
The following code report very often a Invalid Memory Access on the AllocateMemory function.
I also noticed:
- Same with 4.10
- No problem without the debugger
Any suggestion ?
Code: Select all
ProcedureDLL SciLexer_LoadFile(SciGadget.l, MyFile.s) ; Load the file MyFile
Protected MyHandle.l
Protected MyLen.l
Protected *Mem.b
Debug "Load " + MyFile
SciLexer_ActionStatus = 1
If FileSize(MyFile) > -1
MyHandle = ReadFile(#PB_Any, MyFile)
If MyHandle
MyLen = Lof(MyHandle)
Debug MyLen
If MyLen > 0
*Mem = AllocateMemory(MyLen + 1) ;Error at this line
If *Mem
ReadData(MyHandle, *Mem, MyLen)
ScintillaSendMessage(SciGadget, #SCI_SETTEXT, 0,*Mem)
FreeMemory(*Mem)
EndIf
Else
ScintillaSendMessage(SciGadget, #SCI_CLEARALL, 0, 0)
EndIf
CloseFile(MyHandle)
EndIf
EndIf
SciLexer_ActionStatus = 2
EndProcedure