-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in VGUI1 Image Label code #3101
Comments
Adding to this report, this memory leak can be exploited by servers to cause leaks on the client. At the end of this method: Lines 3949 to 4181 in c7240b9
Putting this: //Image need not exist, and must not exist as a resolution-specific image for the code containing the leak to be reached.
const char* fakeBannerImageName = "foo";
//SVC_DIRECTOR messages start with a byte indicating the total size of the message after the size value.
//The next byte is the command id, followed by command-specific values.
const int messageSize = 1 + strlen(fakeBannerImageName) + 1;
//Leak this many stream objects every time we update the player.
for (int i = 0; i < 50; ++i)
{
MESSAGE_BEGIN(MSG_ONE, SVC_DIRECTOR, NULL, pev);
WRITE_BYTE(messageSize);
WRITE_BYTE(DRC_CMD_BANNER);
WRITE_STRING(fakeBannerImageName);
MESSAGE_END();
} This will send 50 director messages every time the server updates the client, each message leaks memory. |
@kisak-valve please, you should offer a job contract to @SamVanheer |
This code leaks
FileInputStream
objects:halflife/cl_dll/vgui_CustomObjects.cpp
Lines 383 to 393 in c7240b9
The object is created but never freed, so repeated calls can use up all memory. It would take an obscene amount of calls to accomplish that though, this leaks about 8 bytes per object (4 bytes for the vtable, 4 bytes for the FILE pointer).
Allocating the stream on the stack will solve this problem:
This is a valid way to use VGUI1 streams. See this code for an example of another stream that is allocated this way:
halflife/game_shared/vgui_loadtga.cpp
Lines 65 to 78 in c7240b9
The text was updated successfully, but these errors were encountered: