Why do I get an access violation when accessing a default argument inside a function

I have a function that has two parameters which have default arguments set

void MyClass::MyFunction(FString parameter1="", FString parameter2=""){
        if(parameter1 == ""){
                  parameter1 = myGlobalVariable;

       if(parameter2 == ""){
                  parameter2 = myGlobalVariable;

It runs and behaves as expected for awhile and then after being called several times it will have an access violation on the second if condition accessing parameter2.
I have tried reorganizing so that the first if statement is parameter2 and the second is parameter1 and in that case it will fail attempting to access parameter1.

I feel like there is something obvious that I’m doing wrong but I just cant see it.

I think your code is like this
you set 2 local variable and no return on them