mirror of
https://github.com/tbamud/tbamud.git
synced 2026-02-24 20:41:44 +01:00
Bug Fix: Fixed major leak with the history system, as well as added a few more memory cleanups to make zmalloc happy.
This commit is contained in:
@@ -57,6 +57,8 @@ char *find_exdesc(char *word, struct extra_descr_data *list);
|
|||||||
void space_to_minus(char *str);
|
void space_to_minus(char *str);
|
||||||
/** @todo Move to a help module? */
|
/** @todo Move to a help module? */
|
||||||
int search_help(const char *argument, int level);
|
int search_help(const char *argument, int level);
|
||||||
|
void free_history(struct char_data *ch, int type);
|
||||||
|
void free_recent_players(void);
|
||||||
/* functions with subcommands */
|
/* functions with subcommands */
|
||||||
/* do_commands */
|
/* do_commands */
|
||||||
ACMD(do_commands);
|
ACMD(do_commands);
|
||||||
|
|||||||
@@ -2223,24 +2223,22 @@ ACMD(do_wiznet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (level > LVL_IMMORT) {
|
if (level > LVL_IMMORT) {
|
||||||
snprintf(buf1, sizeof(buf1), "@c%s: <%d> %s%s@n\r\n", GET_NAME(ch), level, emote ? "<--- " : "", argument);
|
snprintf(buf1, sizeof(buf1), "@c%s: <%d> %s%s@n", GET_NAME(ch), level, emote ? "<--- " : "", argument);
|
||||||
snprintf(buf2, sizeof(buf1), "@cSomeone: <%d> %s%s@n\r\n", level, emote ? "<--- " : "", argument);
|
snprintf(buf2, sizeof(buf1), "@cSomeone: <%d> %s%s@n", level, emote ? "<--- " : "", argument);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf1, sizeof(buf1), "@c%s: %s%s@n\r\n", GET_NAME(ch), emote ? "<--- " : "", argument);
|
snprintf(buf1, sizeof(buf1), "@c%s: %s%s@n", GET_NAME(ch), emote ? "<--- " : "", argument);
|
||||||
snprintf(buf2, sizeof(buf1), "@cSomeone: %s%s@n\r\n", emote ? "<--- " : "", argument);
|
snprintf(buf2, sizeof(buf1), "@cSomeone: %s%s@n", emote ? "<--- " : "", argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (d = descriptor_list; d; d = d->next) {
|
for (d = descriptor_list; d; d = d->next) {
|
||||||
if (IS_PLAYING(d) && (GET_LEVEL(d->character) >= level) &&
|
if (IS_PLAYING(d) && (GET_LEVEL(d->character) >= level) &&
|
||||||
(!PRF_FLAGGED(d->character, PRF_NOWIZ))
|
(!PRF_FLAGGED(d->character, PRF_NOWIZ))
|
||||||
&& (d != ch->desc || !(PRF_FLAGGED(d->character, PRF_NOREPEAT)))) {
|
&& (d != ch->desc || !(PRF_FLAGGED(d->character, PRF_NOREPEAT)))) {
|
||||||
if (CAN_SEE(d->character, ch)) {
|
if (CAN_SEE(d->character, ch))
|
||||||
msg = strdup(buf1);
|
msg = act(buf1, FALSE, d->character, 0, 0, TO_CHAR | DG_NO_TRIG);
|
||||||
send_to_char(d->character, "%s", buf1);
|
else
|
||||||
} else {
|
msg = act(buf2, FALSE, d->character, 0, 0, TO_CHAR | DG_NO_TRIG);
|
||||||
msg = strdup(buf2);
|
|
||||||
send_to_char(d->character, "%s", buf2);
|
|
||||||
}
|
|
||||||
add_history(d->character, msg, HIST_WIZNET);
|
add_history(d->character, msg, HIST_WIZNET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2466,7 +2464,7 @@ ACMD(do_show)
|
|||||||
struct obj_data *obj;
|
struct obj_data *obj;
|
||||||
struct descriptor_data *d;
|
struct descriptor_data *d;
|
||||||
char field[MAX_INPUT_LENGTH], value[MAX_INPUT_LENGTH],
|
char field[MAX_INPUT_LENGTH], value[MAX_INPUT_LENGTH],
|
||||||
arg[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], temp[MAX_STRING_LENGTH];
|
arg[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH];
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
char colour[16];
|
char colour[16];
|
||||||
|
|
||||||
@@ -4948,6 +4946,20 @@ bool AddRecentPlayer(char *chname, char *chhost, bool newplr, bool cpyplr)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_recent_players(void)
|
||||||
|
{
|
||||||
|
struct recent_player *this;
|
||||||
|
struct recent_player *temp;
|
||||||
|
|
||||||
|
this = recent_list;
|
||||||
|
|
||||||
|
while((temp = this) != NULL)
|
||||||
|
{
|
||||||
|
this = this->next;
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ACMD(do_recent)
|
ACMD(do_recent)
|
||||||
{
|
{
|
||||||
time_t ct;
|
time_t ct;
|
||||||
|
|||||||
@@ -370,8 +370,10 @@ int main(int argc, char **argv)
|
|||||||
free_invalid_list(); /* ban.c */
|
free_invalid_list(); /* ban.c */
|
||||||
free_save_list(); /* genolc.c */
|
free_save_list(); /* genolc.c */
|
||||||
free_strings(&config_info, OASIS_CFG); /* oasis_delete.c */
|
free_strings(&config_info, OASIS_CFG); /* oasis_delete.c */
|
||||||
free_ibt_lists(); /* ibt.c */
|
free_ibt_lists(); /* ibt.c */
|
||||||
free_list(world_events);
|
free_recent_players(); /* act.informative.c */
|
||||||
|
free_list(world_events); /* free up our global lists */
|
||||||
|
free_list(global_lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_act_message)
|
if (last_act_message)
|
||||||
@@ -416,6 +418,9 @@ void copyover_recover()
|
|||||||
/* read boot_time - first line in file */
|
/* read boot_time - first line in file */
|
||||||
i = fscanf(fp, "%ld\n", (long *)&boot_time);
|
i = fscanf(fp, "%ld\n", (long *)&boot_time);
|
||||||
|
|
||||||
|
if (i != 1)
|
||||||
|
log("SYSERR: Error reading boot time.");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
fOld = TRUE;
|
fOld = TRUE;
|
||||||
i = fscanf (fp, "%d %ld %s %s %s\n", &desc, &pref, name, host, guiopt);
|
i = fscanf (fp, "%d %ld %s %s %s\n", &desc, &pref, name, host, guiopt);
|
||||||
|
|||||||
2
src/db.c
2
src/db.c
@@ -3165,7 +3165,7 @@ void free_char(struct char_data *ch)
|
|||||||
free(ch->player.description);
|
free(ch->player.description);
|
||||||
for (i = 0; i < NUM_HIST; i++)
|
for (i = 0; i < NUM_HIST; i++)
|
||||||
if (GET_HISTORY(ch, i))
|
if (GET_HISTORY(ch, i))
|
||||||
free(GET_HISTORY(ch, i));
|
free_history(ch, i);
|
||||||
|
|
||||||
if (ch->player_specials)
|
if (ch->player_specials)
|
||||||
free(ch->player_specials);
|
free(ch->player_specials);
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ void free_list(struct list_data * pList)
|
|||||||
mudlog(CMP, LVL_GOD, TRUE, "List being freed while not empty.");
|
mudlog(CMP, LVL_GOD, TRUE, "List being freed while not empty.");
|
||||||
|
|
||||||
/* Global List for debugging */
|
/* Global List for debugging */
|
||||||
remove_from_list(pList, global_lists);
|
if (pList != global_lists)
|
||||||
|
remove_from_list(pList, global_lists);
|
||||||
|
|
||||||
free(pList);
|
free(pList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,7 @@
|
|||||||
Header files.
|
Header files.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <arpa/telnet.h>
|
#include <arpa/telnet.h>
|
||||||
#include <time.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@@ -292,7 +285,7 @@ protocol_t *ProtocolCreate( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pProtocol = malloc(sizeof(protocol_t));
|
pProtocol = (protocol_t *) malloc(sizeof(protocol_t));
|
||||||
pProtocol->WriteOOB = 0;
|
pProtocol->WriteOOB = 0;
|
||||||
pProtocol->bIACMode = false;
|
pProtocol->bIACMode = false;
|
||||||
pProtocol->bNegotiated = false;
|
pProtocol->bNegotiated = false;
|
||||||
@@ -310,11 +303,11 @@ protocol_t *ProtocolCreate( void )
|
|||||||
pProtocol->ScreenHeight = 0;
|
pProtocol->ScreenHeight = 0;
|
||||||
pProtocol->pMXPVersion = AllocString("Unknown");
|
pProtocol->pMXPVersion = AllocString("Unknown");
|
||||||
pProtocol->pLastTTYPE = NULL;
|
pProtocol->pLastTTYPE = NULL;
|
||||||
pProtocol->pVariables = malloc(sizeof(MSDP_t*)*eMSDP_MAX);
|
pProtocol->pVariables = (MSDP_t **) malloc(sizeof(MSDP_t*)*eMSDP_MAX);
|
||||||
|
|
||||||
for ( i = eMSDP_NONE+1; i < eMSDP_MAX; ++i )
|
for ( i = eMSDP_NONE+1; i < eMSDP_MAX; ++i )
|
||||||
{
|
{
|
||||||
pProtocol->pVariables[i] = malloc(sizeof(MSDP_t));
|
pProtocol->pVariables[i] = (MSDP_t *) malloc(sizeof(MSDP_t));
|
||||||
pProtocol->pVariables[i]->bReport = false;
|
pProtocol->pVariables[i]->bReport = false;
|
||||||
pProtocol->pVariables[i]->bDirty = false;
|
pProtocol->pVariables[i]->bDirty = false;
|
||||||
pProtocol->pVariables[i]->ValueInt = 0;
|
pProtocol->pVariables[i]->ValueInt = 0;
|
||||||
@@ -350,7 +343,8 @@ void ProtocolDestroy( protocol_t *apProtocol )
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(apProtocol->pVariables);
|
free(apProtocol->pVariables);
|
||||||
free(apProtocol->pLastTTYPE);
|
if (apProtocol->pLastTTYPE) /* Isn't saved over copyover so may still be NULL */
|
||||||
|
free(apProtocol->pLastTTYPE);
|
||||||
free(apProtocol->pMXPVersion);
|
free(apProtocol->pMXPVersion);
|
||||||
free(apProtocol);
|
free(apProtocol);
|
||||||
}
|
}
|
||||||
@@ -554,12 +548,6 @@ const char *ProtocolOutput( descriptor_t *apDescriptor, const char *apData, int
|
|||||||
case 'n':
|
case 'n':
|
||||||
pCopyFrom = s_Clean;
|
pCopyFrom = s_Clean;
|
||||||
break;
|
break;
|
||||||
case 'b': /* dark brown */
|
|
||||||
pCopyFrom = ColourRGB(apDescriptor, "F110");
|
|
||||||
break;
|
|
||||||
case 'B': /* light brown */
|
|
||||||
pCopyFrom = ColourRGB(apDescriptor, "F410");
|
|
||||||
break;
|
|
||||||
case 'd': /* dark grey / black */
|
case 'd': /* dark grey / black */
|
||||||
pCopyFrom = ColourRGB(apDescriptor, "F000");
|
pCopyFrom = ColourRGB(apDescriptor, "F000");
|
||||||
break;
|
break;
|
||||||
@@ -590,10 +578,10 @@ const char *ProtocolOutput( descriptor_t *apDescriptor, const char *apData, int
|
|||||||
case 'Y': /* light yellow */
|
case 'Y': /* light yellow */
|
||||||
pCopyFrom = ColourRGB(apDescriptor, "F550");
|
pCopyFrom = ColourRGB(apDescriptor, "F550");
|
||||||
break;
|
break;
|
||||||
case 'u': /* dark blue */
|
case 'b': /* dark blue */
|
||||||
pCopyFrom = ColourRGB(apDescriptor, "F012");
|
pCopyFrom = ColourRGB(apDescriptor, "F012");
|
||||||
break;
|
break;
|
||||||
case 'U': /* light blue */
|
case 'B': /* light blue */
|
||||||
pCopyFrom = ColourRGB(apDescriptor, "F025");
|
pCopyFrom = ColourRGB(apDescriptor, "F025");
|
||||||
break;
|
break;
|
||||||
case 'm': /* dark magenta */
|
case 'm': /* dark magenta */
|
||||||
@@ -1244,7 +1232,7 @@ void MSDPSetTable( descriptor_t *apDescriptor, variable_t aMSDP, const char *apV
|
|||||||
const char MsdpTableStart[] = { (char)MSDP_TABLE_OPEN, '\0' };
|
const char MsdpTableStart[] = { (char)MSDP_TABLE_OPEN, '\0' };
|
||||||
const char MsdpTableStop[] = { (char)MSDP_TABLE_CLOSE, '\0' };
|
const char MsdpTableStop[] = { (char)MSDP_TABLE_CLOSE, '\0' };
|
||||||
|
|
||||||
char *pTable = malloc(strlen(apValue) + 3); /* 3: START, STOP, NUL */
|
char *pTable = (char *) malloc(strlen(apValue) + 3); /* 3: START, STOP, NUL */
|
||||||
|
|
||||||
strcpy(pTable, MsdpTableStart);
|
strcpy(pTable, MsdpTableStart);
|
||||||
strcat(pTable, apValue);
|
strcat(pTable, apValue);
|
||||||
@@ -1280,7 +1268,7 @@ void MSDPSetArray( descriptor_t *apDescriptor, variable_t aMSDP, const char *apV
|
|||||||
const char MsdpArrayStart[] = { (char)MSDP_ARRAY_OPEN, '\0' };
|
const char MsdpArrayStart[] = { (char)MSDP_ARRAY_OPEN, '\0' };
|
||||||
const char MsdpArrayStop[] = { (char)MSDP_ARRAY_CLOSE, '\0' };
|
const char MsdpArrayStop[] = { (char)MSDP_ARRAY_CLOSE, '\0' };
|
||||||
|
|
||||||
char *pArray = malloc(strlen(apValue) + 3); /* 3: START, STOP, NUL */
|
char *pArray = (char *) malloc(strlen(apValue) + 3); /* 3: START, STOP, NUL */
|
||||||
|
|
||||||
strcpy(pArray, MsdpArrayStart);
|
strcpy(pArray, MsdpArrayStart);
|
||||||
strcat(pArray, apValue);
|
strcat(pArray, apValue);
|
||||||
@@ -2492,7 +2480,7 @@ static char *AllocString( const char *apString )
|
|||||||
if ( apString != NULL )
|
if ( apString != NULL )
|
||||||
{
|
{
|
||||||
int Size = strlen(apString);
|
int Size = strlen(apString);
|
||||||
pResult = malloc(Size+1);
|
pResult = (char *) malloc(Size+1);
|
||||||
if ( pResult != NULL )
|
if ( pResult != NULL )
|
||||||
strcpy( pResult, apString );
|
strcpy( pResult, apString );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user