Page MenuHomeFeedback Tracker

Using static function call that returns new instance of a class as param in call to another method causes segfault
New, NormalPublic

Description

When having a static function that returns a new instance of some class, and using this static function call as parameter to another method, this will cause heap corruption and lead the game to segfault.

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
Modding
Steps To Reproduce

Code example:

class MyType<Class T>: Managed
{
    T m_Value;

    void MyType(T v)
    {
        m_Value = v;
    }
}

static MyType<string> CreateMyType(string s)
{
    return new MyType<string>(s);
}

class MyExample
{
    static void PrintExample(Class p)
    {
        Print(p);
    }
}

Calling MyExample.PrintExample(CreateMyType("test")); will eventually result in a segfault (it may be necessary to call it multiple times until segfault occurs).

Event Timeline

lava76 created this task.Fri, May 23, 12:27 AM