mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-01 16:32:17 +00:00
- fixed memory leaks in network code.
ReadString allocates a buffer, so saving it in a local variable and then forgetting it will not free the buffer afterward. (This should probably be refactored to use some safer methods to read the string than this old-school method...)
This commit is contained in:
parent
74b60adda6
commit
76f7f8062d
1 changed files with 10 additions and 10 deletions
|
@ -2487,10 +2487,10 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
||||||
|
|
||||||
case DEM_RUNNAMEDSCRIPT:
|
case DEM_RUNNAMEDSCRIPT:
|
||||||
{
|
{
|
||||||
char *sname = ReadString(stream);
|
s = ReadString(stream);
|
||||||
int argn = ReadByte(stream);
|
int argn = ReadByte(stream);
|
||||||
|
|
||||||
RunScript(stream, players[player].mo, -FName(sname), argn & 127, (argn & 128) ? ACS_ALWAYS : 0);
|
RunScript(stream, players[player].mo, -FName(s), argn & 127, (argn & 128) ? ACS_ALWAYS : 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2557,9 +2557,9 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
||||||
|
|
||||||
case DEM_KILLCLASSCHEAT:
|
case DEM_KILLCLASSCHEAT:
|
||||||
{
|
{
|
||||||
char *classname = ReadString (stream);
|
s = ReadString (stream);
|
||||||
int killcount = 0;
|
int killcount = 0;
|
||||||
PClassActor *cls = PClass::FindActor(classname);
|
PClassActor *cls = PClass::FindActor(s);
|
||||||
|
|
||||||
if (cls != NULL)
|
if (cls != NULL)
|
||||||
{
|
{
|
||||||
|
@ -2569,20 +2569,20 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
||||||
{
|
{
|
||||||
killcount += KillAll(cls_rep);
|
killcount += KillAll(cls_rep);
|
||||||
}
|
}
|
||||||
Printf ("Killed %d monsters of type %s.\n",killcount, classname);
|
Printf ("Killed %d monsters of type %s.\n",killcount, s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Printf ("%s is not an actor class.\n", classname);
|
Printf ("%s is not an actor class.\n", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DEM_REMOVE:
|
case DEM_REMOVE:
|
||||||
{
|
{
|
||||||
char *classname = ReadString(stream);
|
s = ReadString(stream);
|
||||||
int removecount = 0;
|
int removecount = 0;
|
||||||
PClassActor *cls = PClass::FindActor(classname);
|
PClassActor *cls = PClass::FindActor(s);
|
||||||
if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
|
||||||
{
|
{
|
||||||
removecount = RemoveClass(cls);
|
removecount = RemoveClass(cls);
|
||||||
|
@ -2591,11 +2591,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
||||||
{
|
{
|
||||||
removecount += RemoveClass(cls_rep);
|
removecount += RemoveClass(cls_rep);
|
||||||
}
|
}
|
||||||
Printf("Removed %d actors of type %s.\n", removecount, classname);
|
Printf("Removed %d actors of type %s.\n", removecount, s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Printf("%s is not an actor class.\n", classname);
|
Printf("%s is not an actor class.\n", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue