halflife icon indicating copy to clipboard operation
halflife copied to clipboard

[Condition Zero] Material system leaks memory when parsing configuration files

Open SamVanheer opened this issue 2 years ago • 1 comments

When the material system parses configuration data from material files it frees the file's contents incorrectly. The function MAT_SetDefaults loads the file, parses the data and then passes a null pointer to gEngfuncs.COM_FreeFile.

The cause is the same as #1729: the original pointer is modified during parsing, parsing doesn't end until the pointer becomes null at which point it is passed to gEngfuncs.COM_FreeFile.

The function also doesn't free the memory if the file syntax is incorrect, as it will return from the function without calling FreeFile.

This affects both Condition Zero and Deleted Scenes.

SamVanheer avatar Dec 25 '21 15:12 SamVanheer

The LoadLevelMaterials function also frees a file buffer incorrectly due to the same parsing-related mistake.

SamVanheer avatar Dec 25 '21 17:12 SamVanheer