From 43b81cb69bd8f93922ac0f8773be7ee3fd2ffcae Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 8 Mar 2018 07:40:20 -0500 Subject: [PATCH] assuring that malloc gets freed --- src/rpc/cli.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index 993e19f..2570c9f 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -216,10 +216,20 @@ void cli::getline( const fc::string& prompt, fc::string& line) line_read = readline(prompt.c_str()); if( line_read == nullptr ) FC_THROW_EXCEPTION( fc::eof_exception, "" ); - if( *line_read ) - add_history(line_read); line = line_read; - free(line_read); + if (*line_read) + { + try + { + add_history(line_read); + free(line_read); + } + catch(...) + { + free(line_read); + throw; + } + } }).wait(); } else