Repository: dotnet/runtime
File: src/coreclr/pal/src/thread/process.cpp (C++)

Code before:
        // Copy the createdump argv
        int argc = 0;
        for (; argc < MAX_ARGV_ENTRIES && g_argvCreateDump[argc] != nullptr; argc++)
        {
            argv[argc] = g_argvCreateDump[argc];
        }

        if (signal != 0 && argc < MAX_ARGV_ENTRIES)
        {
            // Add the signal number to the command line
            signalArg = PROCFormatInt(signal);
            if (signalArg != nullptr)
            {
                argv[argc++] = "--signal";
                argv[argc++] = signalArg;
            }

            // Add the current thread id to the command line. This function is always called on the crashing thread.
            crashThreadArg = PROCFormatInt(THREADSilentGetCurrentThreadId());
            if (crashThreadArg != nullptr)
            {
                argv[argc++] = "--crashthread";
                argv[argc++] = crashThreadArg;
            }

            if (siginfo != nullptr && argc < MAX_ARGV_ENTRIES)
            {
                signalCodeArg = PROCFormatInt(siginfo->si_code);
                if (signalCodeArg != nullptr)
                {
                    argv[argc++] = "--code";
                    argv[argc++] = signalCodeArg;
                }
                signalErrnoArg = PROCFormatInt(siginfo->si_errno);
                if (signalErrnoArg != nullptr)
                {
                    argv[argc++] = "--errno";
                    argv[argc++] = signalErrnoArg;
                }
                signalAddressArg = PROCFormatInt64((ULONG64)siginfo->si_addr);
                if (signalAddressArg != nullptr)
                {
                    argv[argc++] = "--address";
                    argv[argc++] = signalAddressArg;
                }
            }
        }

        argv[argc] = nullptr;
        _ASSERTE(argc < MAX_ARGV_ENTRIES);


Review comment (bug):
```suggestion
            if (siginfo != nullptr)
```

Code after:
        // Copy the createdump argv
        int argc = 0;
        for (; argc < MAX_ARGV_ENTRIES && g_argvCreateDump[argc] != nullptr; argc++)
        {
            argv[argc] = g_argvCreateDump[argc];
        }

        if (signal != 0)
        {
            // Add the signal number to the command line
            signalArg = PROCFormatInt(signal);
            if (signalArg != nullptr)
            {
                argv[argc++] = "--signal";
                argv[argc++] = signalArg;
            }

            // Add the current thread id to the command line. This function is always called on the crashing thread.
            crashThreadArg = PROCFormatInt(THREADSilentGetCurrentThreadId());
            if (crashThreadArg != nullptr)
            {
                argv[argc++] = "--crashthread";
                argv[argc++] = crashThreadArg;
            }

            if (siginfo != nullptr)
            {
                signalCodeArg = PROCFormatInt(siginfo->si_code);
                if (signalCodeArg != nullptr)
                {
                    argv[argc++] = "--code";
                    argv[argc++] = signalCodeArg;
                }
                signalErrnoArg = PROCFormatInt(siginfo->si_errno);
                if (signalErrnoArg != nullptr)
                {
                    argv[argc++] = "--errno";
                    argv[argc++] = signalErrnoArg;
                }
                signalAddressArg = PROCFormatInt64((ULONG64)siginfo->si_addr);
                if (signalAddressArg != nullptr)
                {
                    argv[argc++] = "--address";
                    argv[argc++] = signalAddressArg;
                }
            }
        }

        argv[argc] = nullptr;
        _ASSERTE(argc < MAX_ARGV_ENTRIES);