Skip to content

AssignConfigValueTyped: int64-to-int32 conversion dereferences value as pointer#401

Merged
zpostfacto merged 1 commit into
ValveSoftware:masterfrom
thouravi:master
Apr 21, 2026
Merged

AssignConfigValueTyped: int64-to-int32 conversion dereferences value as pointer#401
zpostfacto merged 1 commit into
ValveSoftware:masterfrom
thouravi:master

Conversation

@thouravi

Copy link
Copy Markdown
Contributor

The AssignConfigValueTyped(int32*, ...) overload has a typo in the Int64 case that causes a crash.

Affected code:

int64 arg = *(int64*)pArg;
if ( (int32)arg != arg )
    return false;
*pVal = *(int32*)arg;  // 'arg' treated as a pointer instead of a value

Fix:

int64 arg = *(int64*)pArg;
if ( (int32)arg != arg )
    return false;
*pVal = (int32)arg;

The value of arg is incorrectly cast to a pointer and dereferenced, rather than being cast directly to int32. This will almost certainly cause a segfault or memory corruption at runtime whenever a config value of type int32 is set by passing an int64 argument.

@zpostfacto

Copy link
Copy Markdown
Contributor

Good one!

@zpostfacto zpostfacto merged commit 9ff5f89 into ValveSoftware:master Apr 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants