diff options
author | jackpoz <giacomopoz@gmail.com> | 2013-09-04 21:55:10 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2013-09-04 21:55:10 +0200 |
commit | 5eff0b62aea32174eb32ffb5fb71534a6bf43c6f (patch) | |
tree | ba0bda664dc2f7e994a841a32e86f0423611cd29 /src | |
parent | b3d5784d1f724cf0c5134a3d3e925e3da045115f (diff) |
Core/Command Line: Fix memory leak
Fix memory leak in command line handler on platforms other than Windows. The result of readline() is supposed to be freed with free() as described at http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC24 .
Valgrind log:
11 bytes in 2 blocks are definitely lost in loss record 6 of 61
at 0x4C28BED: malloc (vg_replace_malloc.c:263)
by 0x4E5F6E8: xmalloc (in /lib/x86_64-linux-gnu/libreadline.so.6.2)
by 0x4E4571A: readline_internal_teardown (in /lib/x86_64-linux-gnu/libreadline.so.6.2)
by 0x4E46541: readline (in /lib/x86_64-linux-gnu/libreadline.so.6.2)
by 0x1005284: CliRunnable::run() (CliRunnable.cpp:161)
by 0x163A3DA: ACE_Based::Thread::ThreadTask(void*) (Threading.cpp:186)
by 0x518C555: ACE_OS_Thread_Adapter::invoke() (OS_Thread_Adapter.cpp:103)
by 0x61D7B4F: start_thread (pthread_create.c:304)
by 0x6C66A7C: clone (clone.S:112)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/worldserver/CommandLine/CliRunnable.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index e136269e2a0..1ebb58eef1a 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -175,6 +175,8 @@ void CliRunnable::run() { #if PLATFORM == PLATFORM_WINDOWS printf("TC>"); +#else + free(command_str); #endif continue; } @@ -184,6 +186,8 @@ void CliRunnable::run() { #if PLATFORM == PLATFORM_WINDOWS printf("TC>"); +#else + free(command_str); #endif continue; } @@ -192,6 +196,7 @@ void CliRunnable::run() sWorld->QueueCliCommand(new CliCommandHolder(NULL, command.c_str(), &utf8print, &commandFinished)); #if PLATFORM != PLATFORM_WINDOWS add_history(command.c_str()); + free(command_str); #endif } else if (feof(stdin)) |