diff --git a/Source/Tools/FEXLoader/ELFCodeLoader.h b/Source/Tools/FEXLoader/ELFCodeLoader.h index 733be0317f..99a782c547 100644 --- a/Source/Tools/FEXLoader/ELFCodeLoader.h +++ b/Source/Tools/FEXLoader/ELFCodeLoader.h @@ -655,7 +655,7 @@ class ELFCodeLoader final : public FEX::CodeLoader { } // Set the null terminator for the string - *reinterpret_cast(ArgumentBackingBase + CurrentOffset + ArgSize + 1) = 0; + *reinterpret_cast(ArgumentBackingBase + CurrentOffset + ArgSize) = 0; CurrentOffset += ArgSize + 1; } @@ -667,10 +667,12 @@ class ELFCodeLoader final : public FEX::CodeLoader { EnvpPointers[i] = EnvpBackingBaseGuest + CurrentOffset; // Copy the string in to the final location - memcpy(reinterpret_cast(EnvpBackingBase + CurrentOffset), &EnvironmentVariables[i].at(0), EnvpSize); + if (EnvpSize) { + memcpy(reinterpret_cast(EnvpBackingBase + CurrentOffset), &EnvironmentVariables[i].at(0), EnvpSize); + } // Set the null terminator for the string - *reinterpret_cast(EnvpBackingBase + CurrentOffset + EnvpSize + 1) = 0; + *reinterpret_cast(EnvpBackingBase + CurrentOffset + EnvpSize) = 0; CurrentOffset += EnvpSize + 1; }