Toggle navigation
Hercules
Bugtracker archive
Hercules bug tracker archive
Hercules Bug Archives
Core
clif_parse_GlobalMessage memory leak
clif_parse_GlobalMessage memory leak
Warning!
This is the old Hercules bugtracker archive, and may not reflect the current state of Hercules. The current bugtracker is on
GitHub Issues
.
Issue information
Issue ID
#5192
Status
Fixed
Severity
Fair
Started
Hercules Elf Bot
Jan 1, 2012 19:37
Last Post
Hercules Elf Bot
Apr 18, 2012 15:53
Confirmation
Yes (2)
No (0)
Hercules Elf Bot -
Jan 1, 2012 19:37
Originally posted by [b]GreenBox[/b]
On clif_parse_GlobalMessage:
[code]if( ( is_fake = ( sd->fakename[0] ) ) )
{
fakename = (char*) malloc(strlen(sd->fakename)+messagelen+3);
strcpy(fakename, sd->fakename);
strcat(fakename, " : ");
strcat(fakename, message);
textlen = strlen(fakename) + 1;
} [/code]
fakename is malloc'd but never free'd [s]and static buffer can be used on this case with NAME_LENGHT+4 byte.[/s]forget this
also it's better to use CREATE or aMalloc to alloc using emulator memory manager.
correction:
change
[code]fakename = (char*) malloc(strlen(sd->fakename)+messagelen+3);[/code]
to
[code]fakename = (char*) aMalloc(strlen(sd->fakename)+messagelen+3);[/code]
and add before return:
[code]if (is_fake) aFree(fakename);[/code]
This post has been edited by
GreenBox
on Jan 1, 2012 19:46
Hercules Elf Bot -
Jan 1, 2012 22:42
Originally posted by [b]Ind[/b]
Fixed in [rev=15349]