From: <cha...@us...> - 2008-03-27 01:49:18
|
Revision: 425 http://sipp.svn.sourceforge.net/sipp/?rev=425&view=rev Author: charlespwright Date: 2008-03-26 18:49:10 -0700 (Wed, 26 Mar 2008) Log Message: ----------- Fix: Correct memory leaks. Modified Paths: -------------- sipp/trunk/actions.cpp sipp/trunk/call.cpp sipp/trunk/screen.cpp sipp/trunk/sipp.cpp sipp/trunk/variables.cpp Modified: sipp/trunk/actions.cpp =================================================================== --- sipp/trunk/actions.cpp 2008-02-01 17:01:40 UTC (rev 424) +++ sipp/trunk/actions.cpp 2008-03-27 01:49:10 UTC (rev 425) @@ -499,11 +499,7 @@ delete [] M_subVarId; M_subVarId = NULL; } - if(M_stringValue != NULL) - { - delete [] M_stringValue; - M_stringValue = NULL; - } + free(M_stringValue); #ifdef PCAPPLAY if (M_pcapArgs != NULL) { free(M_pcapArgs); @@ -514,6 +510,9 @@ regfree(&M_internalRegExp); free(M_regularExpression); } + if (M_distribution) { + delete M_distribution; + } } /****************************** CActions class ************************/ Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2008-02-01 17:01:40 UTC (rev 424) +++ sipp/trunk/call.cpp 2008-03-27 01:49:10 UTC (rev 425) @@ -1631,6 +1631,9 @@ void free_default_messages() { int messages = sizeof(default_message_strings)/sizeof(default_message_strings[0]); + if (!default_messages) { + return; + } for (int i = 0; i < messages; i++) { delete default_messages[i]; } Modified: sipp/trunk/screen.cpp =================================================================== --- sipp/trunk/screen.cpp 2008-02-01 17:01:40 UTC (rev 424) +++ sipp/trunk/screen.cpp 2008-03-27 01:49:10 UTC (rev 425) @@ -105,8 +105,12 @@ } // Get failed calls counter value before releasing objects - counter_value_failed = display_scenario->stats->GetStat (CStat::CPT_C_FailedCall); - counter_value_success = display_scenario->stats->GetStat (CStat::CPT_C_SuccessfulCall); + if (display_scenario) { + counter_value_failed = display_scenario->stats->GetStat (CStat::CPT_C_FailedCall); + counter_value_success = display_scenario->stats->GetStat (CStat::CPT_C_SuccessfulCall); + } else { + rc = EXIT_TEST_FAILED; + } releaseGlobalAllocations(); Modified: sipp/trunk/sipp.cpp =================================================================== --- sipp/trunk/sipp.cpp 2008-02-01 17:01:40 UTC (rev 424) +++ sipp/trunk/sipp.cpp 2008-03-27 01:49:10 UTC (rev 425) @@ -707,6 +707,11 @@ #define SIPP_ENDL "\r\n" + /* We are not initialized yet. */ + if (!display_scenario) { + return; + } + /* Optional timestamp line for files only */ if(f != stdout) { time_t tim; @@ -1347,7 +1352,7 @@ { static int first = 1; - if(backgroundMode == false) { + if(backgroundMode == false && display_scenario) { if(!last) { screen_clear(); } @@ -3775,6 +3780,13 @@ print_statistics(1); } +void freeInFiles() { + for (file_map::iterator file_it = inFiles.begin(); file_it != inFiles.end(); file_it++) { + delete file_it->second; + //inFiles.erase(file_it->first); + } +} + void releaseGlobalAllocations() { int i,j; @@ -3783,6 +3795,9 @@ delete main_scenario; delete ooc_scenario; free_default_messages(); + freeInFiles(); + delete globalVariables; + delete userVariables; } void stop_all_traces() Modified: sipp/trunk/variables.cpp =================================================================== --- sipp/trunk/variables.cpp 2008-02-01 17:01:40 UTC (rev 424) +++ sipp/trunk/variables.cpp 2008-03-27 01:49:10 UTC (rev 425) @@ -100,9 +100,7 @@ void CCallVariable::setString(char *P_val) { M_type = E_VT_STRING; - if(M_stringValue != NULL) { - delete [] M_stringValue; - } + free(M_stringValue); M_stringValue = P_val; } @@ -179,9 +177,7 @@ delete [] M_matchingValue; } M_matchingValue = NULL; - if(M_stringValue != NULL) { - delete [] M_stringValue; - } + free(M_stringValue); } #define LEVEL_BITS 8 @@ -261,6 +257,9 @@ if (parent) { parent->putTable(); } + for (int i = 0; i < size; i++) { + delete variableTable[i]; + } free(variableTable); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |