sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

SetVariantString uses string by reference

Open Alienmario opened this issue 7 months ago • 0 comments

Help us help you

  • [x] I have checked that my issue doesn't exist yet.
  • [x] I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • [x] I can always reproduce the issue with the provided description below.

SourceMod Version: 1.12.0.7031

Description

SetVariantString will keep a reference to Sourcepawn string variable, instead of copying its value. Not sure if this is intentional, if it is, should probably be specified in the docs.

Problematic Code (or Steps to Reproduce)

The following results in both the input and variant being "IgniteLifetime" The expected behavior is variant being "2".

char buffer[128];
buffer = "2";
SetVariantString(buffer);
buffer = "IgniteLifetime";
AcceptEntityInput(entity, buffer);

Alienmario avatar Jul 21 '24 20:07 Alienmario