View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000407Soldat Dedicated ServerScripting Corepublic2013-09-02 15:162016-06-24 19:10
Assigned ToExHunter 
PlatformOSOS Version
Product Version2.7.5 
Target VersionFixed in Version 
Summary0000407: Calling an invalid function pointer
DescriptionCalling a function pointer that is left unassigned or is nil results in calling an almost-random function.
Steps To ReproduceRefer to code in Additional Information for some example code. To reproduce, call a function pointer that value is nil.
Additional InformationIn this particular example, the unnamed initialization function (the `begin` and `end.` function) is called by Func0 and Func1 when they are nil. I have witnessed situations where other functions are called, and not just this initialization function.

    TFunc0 = function(): byte;
    TFunc1 = function(const V1: byte): byte;

    First: boolean;
    Func0: TFunc0;
    Func1: TFunc1;

function MyFunc0(): byte;
    Result := 1;

function MyFunc1(const V1: byte): byte;
    Result := 2*V1 + 3;


    if (First) then begin
        WriteLn('I already ran this code!');

    First := true;

    WriteLn('Calling Func0');
    WriteLn('Result=' + InttoStr(Func0()));

    WriteLn('Calling Func1');
    WriteLn('Result=' + InttoStr(Func1(10)));

    WriteLn('Setting Func0 and Func1 to existing functions');
    Func0 := @MyFunc0;
    Func1 := @MyFunc1;

    WriteLn('Calling Func0');
    WriteLn('Result=' + InttoStr(Func0()));

    WriteLn('Calling Func1');
    WriteLn('Result=' + InttoStr(Func1(10)));

    WriteLn('Setting Func0 and Func1 to nil');
    Func0 := nil;
    Func1 := nil;

    WriteLn('Calling Func0');
    WriteLn('Result=' + InttoStr(Func0()));

    WriteLn('Calling Func1');
    WriteLn('Result=' + InttoStr(Func1(10)));

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
Falcon (administrator)
2013-09-02 15:34

Use attachments next time please
ExHunter (developer)
2014-10-23 03:48
edited on: 2014-12-11 22:13

We will update our libraries for that, please provide feedback after the release of 1.6.8, if this still occurs then.

Edit: Not yet, sorry. Probably scheduled for 1.6.9/1.7

Edit2: Updated for 1.6.9

ExHunter (developer)
2016-06-24 19:10

I need feedback for this one.

- Issue History
Date Modified Username Field Change
2013-09-02 15:16 DorkeyDear New Issue
2013-09-02 15:34 Falcon Note Added: 0001888
2013-09-02 15:34 Falcon Assigned To => Falcon
2013-09-02 15:34 Falcon Status new => acknowledged
2013-12-27 23:36 Falcon Assigned To Falcon =>
2014-10-23 03:48 ExHunter Note Added: 0002350
2014-10-23 03:48 ExHunter Assigned To => ExHunter
2014-10-23 03:48 ExHunter Status acknowledged => feedback
2014-10-27 03:39 ExHunter Note Edited: 0002350 View Revisions
2014-10-27 03:39 ExHunter Note Edited: 0002350 View Revisions
2014-12-11 22:13 ExHunter Note Edited: 0002350 View Revisions
2016-06-24 19:10 ExHunter Note Added: 0002556

Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker