InjectFix icon indicating copy to clipboard operation
InjectFix copied to clipboard

Init `out struct` parameters to prevent NullReferenceException

Open UlyssesWu opened this issue 2 years ago • 1 comments

Reason:

https://github.com/Tencent/InjectFix/blob/552da3654e74c4b08bbe2533699fb2306df5de7e/Source/VSProj/Src/Core/StackOperation.cs#L256-L260

Known issue, but never fixed😅

Test case:

        public struct TestStruct
        {
            public int a;
            public string b;
        }

        [Patch]
        public void TestOutStruct(out TestStruct ts)
        {
            ts.a = 114514;
            ts.b = "buggy IFix";
        }

        public void Awake() // must not be [Patch]ed
        {
            TestStruct ts;
            TestOutStruct(out ts);
        }

UlyssesWu avatar Oct 31 '23 12:10 UlyssesWu

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

tencent-adm avatar Oct 31 '23 12:10 tencent-adm