Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40f26b5

Browse files
committed
Issue 83. Changed provided by Alexey-T
1 parent 5a961b2 commit 40f26b5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

PythonForDelphi/Components/Sources/Core/MethodCallBack.pas

+7-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ procedure GetCodeMem(var ptr: PByte; size: integer);
181181
{$ELSE}
182182
//page := GetMem(PageSize);
183183
page := mmap(Pointer($10000000), PageSize, PROT_NONE, MAP_PRIVATE or MAP_ANON, -1, 0);
184-
mprotect(page, PageSize, PROT_READ or PROT_WRITE or PROT_EXEC);
184+
if page=Pointer(-1) then //MMAP_FAILED result?
185+
begin
186+
ptr := nil;
187+
exit;
188+
end;
189+
mprotect(page, PageSize, PROT_READ or PROT_WRITE or PROT_EXEC);
185190
{$ENDIF}
186191
page^.next:=CodeMemPages;
187192
CodeMemPages:=page;
@@ -451,6 +456,7 @@ function GetCallBack( self: TObject; method: Pointer;
451456
Inc(lCount,sizeof(c64jump));
452457

453458
GetCodeMem(Q,lCount);
459+
if Q=nil then exit(nil);
454460
P := Q;
455461

456462
lSize := 0;

0 commit comments

Comments
 (0)