library/src/blockclass/BP-BlockClass.cc
// Default deconstructor (no memory should escape this).  All
// of the methods called below do initial null checks to ensure
// that the parameters they're being called on, are set.
Default deconstructor (no memory should escape this).  All
of the methods called below do initial null checks to ensure
that the parameters they're being called on, are set.
Default deconstructor ( no memory should escape this ) . All of the methods called below do initial null checks to ensure that the parameters they ' re being called on are set .
Block::~Block()
{
	BP_BLOCK_ENTER_CRITICAL_SECTION;
	if(this->sha1_ascii)
	{
		tq_free(this->tq, this->sha1_ascii);
		this->sha1_ascii = NULL;
	}
#ifdef BP_BLOCKCLASS_INCLUDE_USER_DB
	if(this->user_info)
	{
		this->destroyAuthUserData();
	}
#endif 
#ifdef BP_BLOCKCLASS_INCLUDE_BING_SCRAPING_INTERFACE
	this->destroyBingSession();
#endif 
#ifdef BP_BLOCKCLASS_INCLUDE_GOOGLE_SCRAPING_INTERFACE
	this->destroyGoogleSession();
#endif 
#ifdef BP_BLOCKCLASS_INCLUDE_YAHOO_SCRAPING_INTERFACE
	this->destroyYahooSession();
#endif 
	this->DestroyChain();
	this->DestroyErrorsAndWarnings();
	this->DestroyUsableProxySet();
	this->destroyWebResultStackWhereClauses();
	if(this->webAssessment)
	{
		this->DestroyWebAssessment(false, true, true);
		this->webAssessment = NULL;
		this->htmlExtraction = NULL;
	}
	if(this->htmlExtraction)
	{
		this->HtmlDestroyExtraction();
		this->htmlExtraction = NULL;
	}
	if(this->mysqlSession)
	{
		this->mysqlDestroyStatement();
		this->MysqlClose();
		this->mysqlSession = NULL;
	}
	this->destroyWebJITExpressionData();
	this->SockDestroy();
	this->File_DestroyFileList();
	this->File_DestroySearchList();
	this->destroyProxyDBRelatedData();
	this->destroyWebResultStack();
	if(this->unparsedHtml)
	{
		tq_free(this->tq, this->unparsedHtml);
		this->unparsedHtml = NULL;
		this->unparsedHtmlLen = 0;
	}
	if(this->result_stack_builder)
	{
		delete this->result_stack_builder;
		this->result_stack_builder = NULL;
	}
	if (this->net_handle)
	{
		BP_DestroyNetworkHandle(this->net_handle);
		net_handle = NULL;
	}
	if(this->gc)
	{
		BP_DestroyGarbageCollector(this->gc);
		this->gc = NULL;
	}
	this->destroyWebResultStack();
	this->destroyWebJITExpressionData();
	this->destroyProxyDBRelatedData();
	this->HttpCloseDestroySession();
	if(this->cc_session)
	{
		BP_DestroyCCSession(this->cc_session);
		this->cc_session = NULL;
	}
	if(this->fdSet)
	{
		tq_free(this->tq, this->fdSet);
		this->fdSet = NULL;
	}
	if(this->got_contents)
	{
		tq_free(this->tq, this->got_contents);
		this->got_contents = NULL;
	}
	if(!this->tq)
		return;
	if(this->tq->total_allocations != 0)
	{
		if(BLOCK_CLASS_DEBUG_DECONSTRUCTOR_MEMORY_MESSAGES)
		{
			printf("\n [+] Error: Destroying block which still currently has allocations.");
			printf("\n [+] Information Below: ");
			BP_DisplayLinkL(this->tq);
		}
	}
#ifdef BP_BLOCKCLASS_INCLUDE_USE_OLD_PTHREAD_METHODS
	sem_destroy(&this->thread_info.lock);
	this->DestroyAllThreads();
#endif
#ifdef BP_BLOCKCLASS_INCLUDE_USE_NEW_PTHREAD_METHODS
	if(this->thread_manager)
	{
		BP_RejoinAllThreads(this->thread_manager);
		BP_DestroyThreadManager(this->thread_manager);
		this->thread_manager = NULL;
	}
#endif
	if(this->cmd_injection_assessment)
	{
		this->DestroyCommandInjectionSession();
		this->cmd_injection_assessment = NULL;
	}
	this->disable_result_lookups_due_to_duplicate_key_contention_fix = 0;
	BP_DestroyLinkL(this->tq, BP_TRUE);
	this->tq = NULL;
	BP_BLOCK_LEAVE_CRITICAL_SECTION;
	BP_DestroyHashTableRegistry(this->system_hreg);
}
Block :: ~ Block ( ) { BP_BLOCK_ENTER_CRITICAL_SECTION ; if ( this -> sha1_ascii ) { tq_free ( this -> tq , this -> sha1_ascii ) ; this -> sha1_ascii = NULL ; } #ifdef BP_BLOCKCLASS_INCLUDE_USER_DB if ( this -> user_info ) { this -> destroyAuthUserData ( ) ; } #endif #ifdef BP_BLOCKCLASS_INCLUDE_BING_SCRAPING_INTERFACE this -> destroyBingSession ( ) ; #endif #ifdef BP_BLOCKCLASS_INCLUDE_GOOGLE_SCRAPING_INTERFACE this -> destroyGoogleSession ( ) ; #endif #ifdef BP_BLOCKCLASS_INCLUDE_YAHOO_SCRAPING_INTERFACE this -> destroyYahooSession ( ) ; #endif this -> DestroyChain ( ) ; this -> DestroyErrorsAndWarnings ( ) ; this -> DestroyUsableProxySet ( ) ; this -> destroyWebResultStackWhereClauses ( ) ; if ( this -> webAssessment ) { this -> DestroyWebAssessment ( false , true , true ) ; this -> webAssessment = NULL ; this -> htmlExtraction = NULL ; } if ( this -> htmlExtraction ) { this -> HtmlDestroyExtraction ( ) ; this -> htmlExtraction = NULL ; } if ( this -> mysqlSession ) { this -> mysqlDestroyStatement ( ) ; this -> MysqlClose ( ) ; this -> mysqlSession = NULL ; } this -> destroyWebJITExpressionData ( ) ; this -> SockDestroy ( ) ; this -> File_DestroyFileList ( ) ; this -> File_DestroySearchList ( ) ; this -> destroyProxyDBRelatedData ( ) ; this -> destroyWebResultStack ( ) ; if ( this -> unparsedHtml ) { tq_free ( this -> tq , this -> unparsedHtml ) ; this -> unparsedHtml = NULL ; this -> unparsedHtmlLen = 0 ; } if ( this -> result_stack_builder ) { delete this -> result_stack_builder ; this -> result_stack_builder = NULL ; } if ( this -> net_handle ) { BP_DestroyNetworkHandle ( this -> net_handle ) ; net_handle = NULL ; } if ( this -> gc ) { BP_DestroyGarbageCollector ( this -> gc ) ; this -> gc = NULL ; } this -> destroyWebResultStack ( ) ; this -> destroyWebJITExpressionData ( ) ; this -> destroyProxyDBRelatedData ( ) ; this -> HttpCloseDestroySession ( ) ; if ( this -> cc_session ) { BP_DestroyCCSession ( this -> cc_session ) ; this -> cc_session = NULL ; } if ( this -> fdSet ) { tq_free ( this -> tq , this -> fdSet ) ; this -> fdSet = NULL ; } if ( this -> got_contents ) { tq_free ( this -> tq , this -> got_contents ) ; this -> got_contents = NULL ; } if ( ! this -> tq ) return ; if ( this -> tq -> total_allocations != 0 ) { if ( BLOCK_CLASS_DEBUG_DECONSTRUCTOR_MEMORY_MESSAGES ) { printf ( " \n " ) ; printf ( " \n " ) ; BP_DisplayLinkL ( this -> tq ) ; } } #ifdef BP_BLOCKCLASS_INCLUDE_USE_OLD_PTHREAD_METHODS sem_destroy ( & this -> thread_info . lock ) ; this -> DestroyAllThreads ( ) ; #endif #ifdef BP_BLOCKCLASS_INCLUDE_USE_NEW_PTHREAD_METHODS if ( this -> thread_manager ) { BP_RejoinAllThreads ( this -> thread_manager ) ; BP_DestroyThreadManager ( this -> thread_manager ) ; this -> thread_manager = NULL ; } #endif if ( this -> cmd_injection_assessment ) { this -> DestroyCommandInjectionSession ( ) ; this -> cmd_injection_assessment = NULL ; } this -> disable_result_lookups_due_to_duplicate_key_contention_fix = 0 ; BP_DestroyLinkL ( this -> tq , BP_TRUE ) ; this -> tq = NULL ; BP_BLOCK_LEAVE_CRITICAL_SECTION ; BP_DestroyHashTableRegistry ( this -> system_hreg ) ; }
Default deconstructor (no memory should escape this).
Default deconstructor ( no memory should escape this ) .
// enter the critical section // ensure we destroy the sha1 data if necessary // BP_BLOCKCLASS_INCLUDE_USER_DB // BP_BLOCKCLASS_INCLUDE_BING_SCRAPING_INTERFACE // BP_BLOCKCLASS_INCLUDE_GOOGLE_SCRAPING_INTERFACE // BP_BLOCKCLASS_INCLUDE_YAHOO_SCRAPING_INTERFACE // destroy buffer chain (if set) // destroy local errors and warnings (if any exist) // destroy usable proxy set if they exist // destroly dynamic web result stack where clauses // check web assessment (only destroy extraction or assessment, as assessment // destroy method auto destroys the extraction) // destroy the web assessment // destroy network handle objects // this is where you could bpfree non-free'd pointers // destroy web result data // destroy jit expression data if necessary // destroy proxy db related data if necessary // close http session if necessary (destroys all data) // destroy command and control session if set // destroy the fd set where necessary // destroy got contents if set // only continue if we have a valid allocator // display debug information if so set // destroy thread info lock // destroy thread items if they're set // destroy the thread manager if set // rejoin all threads // create new thread manager // set the thread manager to null // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Destroy Command Injection Assessment %%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // if we have a command injection assessment, destroy it here // destroy the command injection session here // command injection assessment // init dupe lookups // destroy all allocated memory // set tq to null // leave critical section before destroying system hreg // destroy the hash table registry