mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-06 05:02:40 +03:00
All freed pointers are NULLed
This commit is contained in:
@@ -933,7 +933,7 @@ typedef void (*httplib_alloc_callback_func)( const char *file, unsigned line, co
|
||||
#define httplib_realloc(a, b) XX_httplib_realloc_ex(a, b, __FILE__, __LINE__)
|
||||
|
||||
LIBHTTP_API void * XX_httplib_calloc_ex( size_t count, size_t size, const char *file, unsigned line );
|
||||
LIBHTTP_API void XX_httplib_free_ex( void *memory, const char *file, unsigned line );
|
||||
LIBHTTP_API void * XX_httplib_free_ex( void *memory, const char *file, unsigned line );
|
||||
LIBHTTP_API void * XX_httplib_malloc_ex( size_t size, const char *file, unsigned line );
|
||||
LIBHTTP_API void * XX_httplib_realloc_ex( void *memory, size_t newsize, const char *file, unsigned line );
|
||||
|
||||
|
@@ -47,7 +47,7 @@ int XX_httplib_check_acl( struct httplib_context *ctx, uint32_t remote_ip ) {
|
||||
|
||||
if ( ctx == NULL ) return -1;
|
||||
|
||||
list = ctx->cfg[ACCESS_CONTROL_LIST];
|
||||
list = ctx->access_control_list;
|
||||
|
||||
if ( list == NULL ) allowed = '+';
|
||||
else allowed = '-';
|
||||
|
@@ -46,10 +46,7 @@ void XX_httplib_close_all_listening_sockets( struct httplib_context *ctx ) {
|
||||
ctx->listening_sockets[i].sock = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
httplib_free( ctx->listening_sockets );
|
||||
httplib_free( ctx->listening_socket_fds );
|
||||
|
||||
ctx->listening_sockets = NULL;
|
||||
ctx->listening_socket_fds = NULL;
|
||||
ctx->listening_sockets = httplib_free( ctx->listening_sockets );
|
||||
ctx->listening_socket_fds = httplib_free( ctx->listening_socket_fds );
|
||||
|
||||
} /* XX_close_all_listening_sockets */
|
||||
|
@@ -124,12 +124,12 @@ void httplib_close_connection( struct httplib_connection *conn ) {
|
||||
if ( client_ctx->workerthreadids[i] != 0 ) httplib_pthread_join( client_ctx->workerthreadids[i], NULL );
|
||||
}
|
||||
|
||||
httplib_free( client_ctx->workerthreadids );
|
||||
httplib_free( client_ctx );
|
||||
client_ctx->workerthreadids = httplib_free( client_ctx->workerthreadids );
|
||||
client_ctx = httplib_free( client_ctx );
|
||||
|
||||
httplib_pthread_mutex_destroy( & conn->mutex );
|
||||
|
||||
httplib_free( conn );
|
||||
conn = httplib_free( conn );
|
||||
}
|
||||
|
||||
} /* httplib_close_connection */
|
||||
|
@@ -46,7 +46,7 @@ LIBHTTP_API int httplib_closedir( DIR *dir ) {
|
||||
if ( dir != NULL ) {
|
||||
|
||||
if ( dir->handle != INVALID_HANDLE_VALUE ) result = ( FindClose( dir->handle ) ) ? 0 : -1;
|
||||
httplib_free( dir );
|
||||
dir = httplib_free( dir );
|
||||
}
|
||||
else {
|
||||
|
||||
|
@@ -39,7 +39,6 @@ struct httplib_option XX_httplib_config_options[] = {
|
||||
{ "ssi_pattern", CONFIG_TYPE_EXT_PATTERN, "**.shtml$|**.shtm$" },
|
||||
{ "global_auth_file", CONFIG_TYPE_FILE, NULL },
|
||||
{ "index_files", CONFIG_TYPE_STRING, "index.xhtml,index.html,index.htm,index.cgi,index.shtml,index.php" },
|
||||
{ "access_control_list", CONFIG_TYPE_STRING, NULL },
|
||||
{ "listening_ports", CONFIG_TYPE_STRING, "8080" },
|
||||
{ "document_root", CONFIG_TYPE_DIRECTORY, NULL },
|
||||
{ "ssl_certificate", CONFIG_TYPE_FILE, NULL },
|
||||
|
@@ -97,8 +97,7 @@ static struct httplib_connection *httplib_connect_client_impl( const struct http
|
||||
|
||||
XX_httplib_snprintf( NULL, NULL, ebuf, ebuf_len, "SSL_CTX_new error" );
|
||||
closesocket( sock );
|
||||
httplib_free( conn );
|
||||
conn = NULL;
|
||||
conn = httplib_free( conn );
|
||||
}
|
||||
#endif /* NO_SSL */
|
||||
|
||||
@@ -140,8 +139,7 @@ static struct httplib_connection *httplib_connect_client_impl( const struct http
|
||||
XX_httplib_snprintf( NULL, NULL, ebuf, ebuf_len, "Can not use SSL client certificate" );
|
||||
SSL_CTX_free( conn->client_ssl_ctx );
|
||||
closesocket( sock );
|
||||
httplib_free( conn );
|
||||
conn = NULL;
|
||||
conn = httplib_free( conn );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +156,7 @@ static struct httplib_connection *httplib_connect_client_impl( const struct http
|
||||
XX_httplib_snprintf( NULL, NULL, ebuf, ebuf_len, "SSL connection error" );
|
||||
SSL_CTX_free( conn->client_ssl_ctx );
|
||||
closesocket( sock );
|
||||
httplib_free( conn );
|
||||
conn = NULL;
|
||||
conn = httplib_free( conn );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -86,7 +86,7 @@ struct httplib_connection *httplib_connect_websocket_client( const char *host, i
|
||||
XX_httplib_snprintf( conn, NULL, error_buffer, error_buffer_size, "Unexpected server reply" );
|
||||
}
|
||||
|
||||
if ( conn != NULL ) httplib_free( conn );
|
||||
if ( conn != NULL ) conn = httplib_free( conn );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ struct httplib_connection *httplib_connect_websocket_client( const char *host, i
|
||||
*/
|
||||
|
||||
newctx = httplib_malloc( sizeof(struct httplib_context) );
|
||||
if ( newctx == NULL ) { httplib_free( conn ); return NULL; }
|
||||
if ( newctx == NULL ) { conn = httplib_free( conn ); return NULL; }
|
||||
|
||||
*newctx = *conn->ctx;
|
||||
newctx->user_data = user_data;
|
||||
@@ -106,8 +106,8 @@ struct httplib_connection *httplib_connect_websocket_client( const char *host, i
|
||||
|
||||
if ( newctx->workerthreadids == NULL ) {
|
||||
|
||||
httplib_free( newctx );
|
||||
httplib_free( conn );
|
||||
newctx = httplib_free( newctx );
|
||||
conn = httplib_free( conn );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -117,9 +117,9 @@ struct httplib_connection *httplib_connect_websocket_client( const char *host, i
|
||||
|
||||
if ( thread_data == NULL ) {
|
||||
|
||||
httplib_free( newctx->workerthreadids );
|
||||
httplib_free( newctx );
|
||||
httplib_free( conn );
|
||||
newctx->workerthreadids = httplib_free( newctx->workerthreadids );
|
||||
newctx = httplib_free( newctx );
|
||||
conn = httplib_free( conn );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -137,10 +137,10 @@ struct httplib_connection *httplib_connect_websocket_client( const char *host, i
|
||||
|
||||
if ( XX_httplib_start_thread_with_id( XX_httplib_websocket_client_thread, thread_data, newctx->workerthreadids) != 0 ) {
|
||||
|
||||
httplib_free( thread_data );
|
||||
httplib_free( newctx->workerthreadids );
|
||||
httplib_free( newctx );
|
||||
httplib_free( conn );
|
||||
thread_data = httplib_free( thread_data );
|
||||
newctx->workerthreadids = httplib_free( newctx->workerthreadids );
|
||||
newctx = httplib_free( newctx );
|
||||
conn = httplib_free( conn );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ void XX_httplib_dir_scan_callback( struct de *de, void *data ) {
|
||||
old_entries = dsd->entries;
|
||||
dsd->entries = httplib_realloc( old_entries, dsd->arr_size * sizeof(dsd->entries[0]) );
|
||||
|
||||
if ( dsd->entries == NULL && old_entries != NULL ) httplib_free( old_entries );
|
||||
if ( dsd->entries == NULL && old_entries != NULL ) old_entries = httplib_free( old_entries );
|
||||
}
|
||||
|
||||
if ( dsd->entries == NULL ) {
|
||||
|
@@ -118,7 +118,7 @@ void *event_create(void) {
|
||||
* pthread mutex not available
|
||||
*/
|
||||
|
||||
XX_httplib_free( ret );
|
||||
ret = httplib_free( ret );
|
||||
return NULL;
|
||||
}
|
||||
if ( httplib_pthread_cond_init( & ret->cond, NULL ) != 0 ) {
|
||||
@@ -128,7 +128,7 @@ void *event_create(void) {
|
||||
*/
|
||||
|
||||
httplib_pthread_mutex_destroy( & ret->mutex );
|
||||
XX_httplib_free( ret );
|
||||
ret = httplib_free( ret );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void event_destroy( void *eventhdl ) {
|
||||
httplib_pthread_cond_destroy( & ev->cond );
|
||||
httplib_pthread_mutex_destroy( & ev->mutex );
|
||||
|
||||
XX_httplib_free( ev );
|
||||
ev = httplib_free( ev );
|
||||
|
||||
} /* event_destroy */
|
||||
|
||||
|
@@ -53,18 +53,12 @@ void XX_httplib_free_context( struct httplib_context *ctx ) {
|
||||
|
||||
httplib_pthread_mutex_destroy( & ctx->thread_mutex );
|
||||
#if defined(ALTERNATIVE_QUEUE)
|
||||
if ( ctx->client_socks != NULL ) {
|
||||
|
||||
XX_httplib_free( ctx->client_socks );
|
||||
ctx->client_socks = NULL;
|
||||
}
|
||||
if ( ctx->client_socks != NULL ) ctx->client_socks = httplib_free( ctx->client_socks );
|
||||
|
||||
if ( ctx->client_wait_events != NULL ) {
|
||||
|
||||
for (i=0; (unsigned)i < ctx->cfg_worker_threads; i++) event_destroy( ctx->client_wait_events[i] );
|
||||
XX_httplib_free( ctx->client_wait_events );
|
||||
|
||||
ctx->client_wait_events = NULL;
|
||||
ctx->client_wait_events = httplib_free( ctx->client_wait_events );
|
||||
}
|
||||
#else
|
||||
httplib_pthread_cond_destroy( & ctx->sq_empty );
|
||||
@@ -85,22 +79,19 @@ void XX_httplib_free_context( struct httplib_context *ctx ) {
|
||||
* Deallocate config parameters
|
||||
*/
|
||||
|
||||
if ( ctx->access_log_file != NULL ) { httplib_free( ctx->access_log_file ); ctx->access_log_file = NULL; }
|
||||
if ( ctx->cgi_environment != NULL ) { httplib_free( ctx->cgi_environment ); ctx->cgi_environment = NULL; }
|
||||
if ( ctx->error_log_file != NULL ) { httplib_free( ctx->error_log_file ); ctx->error_log_file = NULL; }
|
||||
if ( ctx->extra_mime_types != NULL ) { httplib_free( ctx->extra_mime_types ); ctx->extra_mime_types = NULL; }
|
||||
if ( ctx->protect_uri != NULL ) { httplib_free( ctx->protect_uri ); ctx->protect_uri = NULL; }
|
||||
if ( ctx->run_as_user != NULL ) { httplib_free( ctx->run_as_user ); ctx->run_as_user = NULL; }
|
||||
if ( ctx->ssl_cipher_list != NULL ) { httplib_free( ctx->ssl_cipher_list ); ctx->ssl_cipher_list = NULL; }
|
||||
if ( ctx->throttle != NULL ) { httplib_free( ctx->throttle ); ctx->throttle = NULL; }
|
||||
if ( ctx->access_control_list != NULL ) ctx->access_control_list = httplib_free( ctx->access_control_list );
|
||||
if ( ctx->access_log_file != NULL ) ctx->access_log_file = httplib_free( ctx->access_log_file );
|
||||
if ( ctx->cgi_environment != NULL ) ctx->cgi_environment = httplib_free( ctx->cgi_environment );
|
||||
if ( ctx->error_log_file != NULL ) ctx->error_log_file = httplib_free( ctx->error_log_file );
|
||||
if ( ctx->extra_mime_types != NULL ) ctx->extra_mime_types = httplib_free( ctx->extra_mime_types );
|
||||
if ( ctx->protect_uri != NULL ) ctx->protect_uri = httplib_free( ctx->protect_uri );
|
||||
if ( ctx->run_as_user != NULL ) ctx->run_as_user = httplib_free( ctx->run_as_user );
|
||||
if ( ctx->ssl_cipher_list != NULL ) ctx->ssl_cipher_list = httplib_free( ctx->ssl_cipher_list );
|
||||
if ( ctx->throttle != NULL ) ctx->throttle = httplib_free( ctx->throttle );
|
||||
|
||||
for (i = 0; i < NUM_OPTIONS; i++) {
|
||||
|
||||
if (ctx->cfg[i] != NULL) {
|
||||
|
||||
httplib_free( ctx->cfg[i] );
|
||||
ctx->cfg[i] = NULL;
|
||||
}
|
||||
if ( ctx->cfg[i] != NULL ) ctx->cfg[i] = httplib_free( ctx->cfg[i] );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -112,8 +103,8 @@ void XX_httplib_free_context( struct httplib_context *ctx ) {
|
||||
tmp_rh = ctx->handlers;
|
||||
ctx->handlers = tmp_rh->next;
|
||||
|
||||
httplib_free( tmp_rh->uri );
|
||||
if ( tmp_rh != NULL ) httplib_free( tmp_rh );
|
||||
tmp_rh->uri = httplib_free( tmp_rh->uri );
|
||||
if ( tmp_rh != NULL ) tmp_rh = httplib_free( tmp_rh );
|
||||
}
|
||||
|
||||
#ifndef NO_SSL
|
||||
@@ -134,11 +125,7 @@ void XX_httplib_free_context( struct httplib_context *ctx ) {
|
||||
* Deallocate worker thread ID array
|
||||
*/
|
||||
|
||||
if ( ctx->workerthreadids != NULL ) {
|
||||
|
||||
httplib_free( ctx->workerthreadids );
|
||||
ctx->workerthreadids = NULL;
|
||||
}
|
||||
if ( ctx->workerthreadids != NULL ) ctx->workerthreadids = httplib_free( ctx->workerthreadids );
|
||||
|
||||
/*
|
||||
* Deallocate the tls variable
|
||||
@@ -159,12 +146,12 @@ void XX_httplib_free_context( struct httplib_context *ctx ) {
|
||||
* deallocate system name string
|
||||
*/
|
||||
|
||||
httplib_free( ctx->systemName );
|
||||
if ( ctx->systemName != NULL ) ctx->systemName = httplib_free( ctx->systemName );
|
||||
|
||||
/*
|
||||
* Deallocate context itself
|
||||
*/
|
||||
|
||||
httplib_free( ctx );
|
||||
ctx = httplib_free( ctx );
|
||||
|
||||
} /* XX_httplib_free_context */
|
||||
|
@@ -306,8 +306,8 @@ void XX_httplib_handle_cgi_request( struct httplib_connection *conn, const char
|
||||
XX_httplib_send_file_data( conn, &fout, 0, INT64_MAX );
|
||||
|
||||
done:
|
||||
httplib_free( blk.var );
|
||||
httplib_free( blk.buf );
|
||||
blk.var = httplib_free( blk.var );
|
||||
blk.buf = httplib_free( blk.buf );
|
||||
|
||||
if ( pid != (pid_t)-1 ) {
|
||||
|
||||
@@ -326,7 +326,7 @@ done:
|
||||
if ( out != NULL ) fclose( out ); else if ( fdout[0] != -1 ) close( fdout[0] );
|
||||
if ( err != NULL ) fclose( err ); else if ( fderr[0] != -1 ) close( fderr[0] );
|
||||
|
||||
if ( buf != NULL ) httplib_free( buf );
|
||||
if ( buf != NULL ) buf = httplib_free( buf );
|
||||
|
||||
} /* XX_httplib_handle_cgi_request */
|
||||
|
||||
|
@@ -95,10 +95,10 @@ void XX_httplib_handle_directory_request( struct httplib_connection *conn, const
|
||||
for (i=0; i<data.num_entries; i++) {
|
||||
|
||||
XX_httplib_print_dir_entry( & data.entries[i] );
|
||||
httplib_free( data.entries[i].file_name );
|
||||
data.entries[i].file_name = httplib_free( data.entries[i].file_name );
|
||||
}
|
||||
|
||||
httplib_free( data.entries );
|
||||
data.entries = httplib_free( data.entries );
|
||||
}
|
||||
|
||||
conn->num_bytes_sent += httplib_printf( conn, "%s", "</table></body></html>" );
|
||||
|
@@ -110,9 +110,8 @@ static int url_encoded_field_get(const struct httplib_connection *conn,
|
||||
httplib_url_decode( key, (int)key_len, key_dec, (int)sizeof(key_dec), 1 );
|
||||
|
||||
value_dec_len = httplib_url_decode( value, (int)value_len, value_dec, (int)value_len + 1, 1 );
|
||||
|
||||
ret = fdh->field_get( key_dec, value_dec, (size_t)value_dec_len, fdh->user_data );
|
||||
httplib_free( value_dec );
|
||||
value_dec = httplib_free( value_dec );
|
||||
|
||||
return ret;
|
||||
|
||||
|
@@ -398,7 +398,6 @@ enum {
|
||||
SSI_EXTENSIONS,
|
||||
GLOBAL_PASSWORDS_FILE,
|
||||
INDEX_FILES,
|
||||
ACCESS_CONTROL_LIST,
|
||||
LISTENING_PORTS,
|
||||
DOCUMENT_ROOT,
|
||||
SSL_CERTIFICATE,
|
||||
@@ -587,6 +586,7 @@ struct httplib_context {
|
||||
#ifdef USE_TIMERS
|
||||
struct ttimers *timers;
|
||||
#endif
|
||||
char * access_control_list;
|
||||
char * access_log_file;
|
||||
char * cgi_environment;
|
||||
char * error_log_file;
|
||||
|
@@ -110,23 +110,26 @@ LIBHTTP_API void *XX_httplib_calloc_ex( size_t count, size_t size, const char *f
|
||||
|
||||
|
||||
/*
|
||||
* void XX_httplib_free_ex( void *memory, const char *file, unsigned file );
|
||||
* void *XX_httplib_free_ex( void *memory, const char *file, unsigned file );
|
||||
*
|
||||
* The function XX_httplib_free_ex() is a hidden function which frees a
|
||||
* previously allocated memory object which was allocated with one of the
|
||||
* LibHTTP allocation functions. The function has the option to do memory
|
||||
* tracking and memory leak debugging through a callback function which can
|
||||
* be registered by the main application.
|
||||
*
|
||||
* The function returns a (void *)NULL pointer which can be used to reset
|
||||
* the value of pointers whose contents has been destroyed.
|
||||
*/
|
||||
|
||||
LIBHTTP_API void XX_httplib_free_ex( void *memory, const char *file, unsigned line ) {
|
||||
LIBHTTP_API void *XX_httplib_free_ex( void *memory, const char *file, unsigned line ) {
|
||||
|
||||
size_t *data;
|
||||
|
||||
if ( memory == NULL ) {
|
||||
|
||||
if ( alloc_log_func != NULL ) alloc_log_func( file, line, "free", 0, httplib_memory_blocks_used, httplib_memory_bytes_used );
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = ((size_t *)memory) - 1;
|
||||
@@ -138,6 +141,8 @@ LIBHTTP_API void XX_httplib_free_ex( void *memory, const char *file, unsigned li
|
||||
|
||||
free( data );
|
||||
|
||||
return NULL;
|
||||
|
||||
} /* XX_httplib_free_ex */
|
||||
|
||||
|
||||
|
@@ -60,10 +60,7 @@ LIBHTTP_API DIR *httplib_opendir( const char *name ) {
|
||||
dir->handle = FindFirstFileW( wpath, &dir->info );
|
||||
dir->result.d_name[0] = '\0';
|
||||
}
|
||||
else {
|
||||
httplib_free( dir );
|
||||
dir = NULL;
|
||||
}
|
||||
else dir = httplib_free( dir );
|
||||
}
|
||||
|
||||
return dir;
|
||||
|
@@ -251,7 +251,7 @@ void XX_httplib_read_websocket( struct httplib_connection *conn, httplib_websock
|
||||
exit_by_callback = 0;
|
||||
if ((ws_data_handler != NULL) && !ws_data_handler(conn, mop, data, data_len, callback_data)) exit_by_callback = 1;
|
||||
|
||||
if ( data != mem ) httplib_free( data );
|
||||
if ( data != mem ) data = httplib_free( data );
|
||||
|
||||
/*
|
||||
* Opcode == 8, connection close
|
||||
|
@@ -111,9 +111,10 @@ void XX_httplib_set_handler_type( struct httplib_context *ctx, const char *uri,
|
||||
/*
|
||||
* remove existing handler
|
||||
*/
|
||||
|
||||
*lastref = tmp_rh->next;
|
||||
httplib_free( tmp_rh->uri );
|
||||
httplib_free( tmp_rh );
|
||||
tmp_rh->uri = httplib_free( tmp_rh->uri );
|
||||
tmp_rh = httplib_free( tmp_rh );
|
||||
}
|
||||
|
||||
httplib_unlock_context(ctx);
|
||||
@@ -149,7 +150,7 @@ void XX_httplib_set_handler_type( struct httplib_context *ctx, const char *uri,
|
||||
if ( tmp_rh->uri == NULL ) {
|
||||
|
||||
httplib_unlock_context( ctx );
|
||||
httplib_free( tmp_rh );
|
||||
tmp_rh = httplib_free( tmp_rh );
|
||||
httplib_cry( ctx, NULL, "%s", "Cannot create new request handler struct, OOM" );
|
||||
|
||||
return;
|
||||
|
@@ -120,7 +120,7 @@ struct httplib_context *httplib_start( const struct httplib_callbacks *callbacks
|
||||
|
||||
httplib_atomic_dec( & XX_httplib_sTlsInit );
|
||||
httplib_cry( ctx, NULL, "Cannot initialize thread local storage" );
|
||||
httplib_free( ctx );
|
||||
ctx = httplib_free( ctx );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ struct httplib_context *httplib_start( const struct httplib_callbacks *callbacks
|
||||
* thread was not created
|
||||
*/
|
||||
|
||||
if ( wta != NULL ) { httplib_free( wta ); wta = NULL; }
|
||||
if ( wta != NULL ) wta = httplib_free( wta );
|
||||
|
||||
if ( i > 0 ) httplib_cry( ctx, NULL, "Cannot start worker thread %i: error %ld", i + 1, (long)ERRNO );
|
||||
|
||||
@@ -284,6 +284,7 @@ static bool process_options( struct httplib_context *ctx, const struct httplib_o
|
||||
|
||||
if ( ctx == NULL ) return false;
|
||||
|
||||
ctx->access_control_list = NULL;
|
||||
ctx->access_log_file = NULL;
|
||||
ctx->allow_sendfile_call = true;
|
||||
ctx->cgi_environment = NULL;
|
||||
@@ -309,6 +310,7 @@ static bool process_options( struct httplib_context *ctx, const struct httplib_o
|
||||
|
||||
while ( options != NULL && options->name != NULL ) {
|
||||
|
||||
if ( check_str( ctx, options, "access_control_list", & ctx->access_control_list ) ) return true;
|
||||
if ( check_file( ctx, options, "access_log_file", & ctx->access_log_file ) ) return true;
|
||||
if ( check_bool( ctx, options, "allow_sendfile_call", & ctx->allow_sendfile_call ) ) return true;
|
||||
if ( check_str( ctx, options, "cgi_environment", & ctx->cgi_environment ) ) return true;
|
||||
@@ -342,7 +344,7 @@ static bool process_options( struct httplib_context *ctx, const struct httplib_o
|
||||
if ( ctx->cfg[idx] != NULL ) {
|
||||
|
||||
httplib_cry( ctx, NULL, "warning: %s: duplicate option", options->name );
|
||||
httplib_free( ctx->cfg[idx] );
|
||||
ctx->cfg[idx] = httplib_free( ctx->cfg[idx] );
|
||||
}
|
||||
|
||||
ctx->cfg[idx] = httplib_strdup( options->value );
|
||||
@@ -417,8 +419,7 @@ static bool check_file( struct httplib_context *ctx, const struct httplib_option
|
||||
|
||||
if ( httplib_strcasecmp( option->name, name ) ) return false;
|
||||
|
||||
if ( *config != NULL ) httplib_free( *config );
|
||||
*config = NULL;
|
||||
if ( *config != NULL ) *config = httplib_free( *config );
|
||||
|
||||
if ( option->value == NULL ) return false;
|
||||
|
||||
@@ -453,8 +454,7 @@ static bool check_str( struct httplib_context *ctx, const struct httplib_option_
|
||||
|
||||
if ( httplib_strcasecmp( option->name, name ) ) return false;
|
||||
|
||||
if ( *config != NULL ) httplib_free( *config );
|
||||
*config = NULL;
|
||||
if ( *config != NULL ) *config = httplib_free( *config );
|
||||
|
||||
if ( option->value == NULL ) return false;
|
||||
|
||||
|
@@ -198,7 +198,7 @@ static void timers_exit( struct httplib_context *ctx ) {
|
||||
if ( ctx->timers != NULL ) {
|
||||
|
||||
httplib_pthread_mutex_destroy( & ctx->timers->mutex );
|
||||
httplib_free( ctx->timers );
|
||||
ctx->timers = httplib_free( ctx->timers );
|
||||
}
|
||||
|
||||
} /* timers_exit */
|
||||
|
@@ -48,7 +48,7 @@ void XX_httplib_tls_dtor( void *key ) {
|
||||
if ( tls->is_master == 2 ) {
|
||||
|
||||
tls->is_master = -3; /* Mark memory as dead */
|
||||
httplib_free( tls );
|
||||
tls = httplib_free( tls );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -64,8 +64,7 @@ void XX_httplib_uninitialize_ssl( struct httplib_context *ctx ) {
|
||||
|
||||
for (i=0; i<CRYPTO_num_locks(); i++) httplib_pthread_mutex_destroy( & XX_httplib_ssl_mutexes[i] );
|
||||
|
||||
httplib_free( XX_httplib_ssl_mutexes );
|
||||
XX_httplib_ssl_mutexes = NULL;
|
||||
XX_httplib_ssl_mutexes = httplib_free( XX_httplib_ssl_mutexes );
|
||||
}
|
||||
|
||||
} /* XX_httplib_unitialize_ssl */
|
||||
|
@@ -44,7 +44,7 @@ static int alloc_vprintf2( char **buf, const char *fmt, va_list ap ) {
|
||||
|
||||
while ( len < 0 ) {
|
||||
|
||||
if ( *buf != NULL ) httplib_free( *buf );
|
||||
if ( *buf != NULL ) *buf = httplib_free( *buf );
|
||||
|
||||
size *= 4;
|
||||
*buf = httplib_malloc( size );
|
||||
@@ -152,7 +152,7 @@ int XX_httplib_vprintf( struct httplib_connection *conn, const char *fmt, va_lis
|
||||
buf = NULL;
|
||||
|
||||
if ( (len = alloc_vprintf( &buf, mem, sizeof(mem), fmt, ap )) > 0 ) len = httplib_write( conn, buf, (size_t)len );
|
||||
if ( buf != mem && buf != NULL ) httplib_free( buf );
|
||||
if ( buf != mem && buf != NULL ) buf = httplib_free( buf );
|
||||
|
||||
return len;
|
||||
|
||||
|
@@ -56,7 +56,7 @@ LIBHTTP_THREAD XX_httplib_websocket_client_thread( void *data ) {
|
||||
|
||||
if ( cdata->close_handler != NULL ) cdata->close_handler( cdata->conn, cdata->callback_data );
|
||||
|
||||
httplib_free( cdata );
|
||||
cdata = httplib_free( cdata );
|
||||
|
||||
return LIBHTTP_THREAD_RETNULL;
|
||||
|
||||
|
@@ -59,7 +59,7 @@ int httplib_websocket_client_write( struct httplib_connection *conn, int opcode,
|
||||
mask_data( data, dataLen, masking_key, masked_data );
|
||||
|
||||
retval = XX_httplib_websocket_write_exec( conn, opcode, masked_data, dataLen, masking_key );
|
||||
httplib_free( masked_data );
|
||||
masked_data = httplib_free( masked_data );
|
||||
|
||||
return retval;
|
||||
|
||||
|
@@ -49,7 +49,7 @@ LIBHTTP_THREAD XX_httplib_worker_thread( void *thread_func_param ) {
|
||||
pwta = thread_func_param;
|
||||
|
||||
worker_thread_run( pwta );
|
||||
httplib_free( thread_func_param );
|
||||
thread_func_param = httplib_free( thread_func_param );
|
||||
}
|
||||
|
||||
return LIBHTTP_THREAD_RETNULL;
|
||||
@@ -158,13 +158,11 @@ static void *worker_thread_run( struct worker_thread_args *thread_args ) {
|
||||
|
||||
if ( conn->request_info.client_cert != NULL ) {
|
||||
|
||||
ptr.con = conn->request_info.client_cert->subject; httplib_free( ptr.var );
|
||||
ptr.con = conn->request_info.client_cert->issuer; httplib_free( ptr.var );
|
||||
ptr.con = conn->request_info.client_cert->serial; httplib_free( ptr.var );
|
||||
ptr.con = conn->request_info.client_cert->finger; httplib_free( ptr.var );
|
||||
httplib_free( conn->request_info.client_cert );
|
||||
|
||||
conn->request_info.client_cert = NULL;
|
||||
ptr.con = conn->request_info.client_cert->subject; ptr.var = httplib_free( ptr.var );
|
||||
ptr.con = conn->request_info.client_cert->issuer; ptr.var = httplib_free( ptr.var );
|
||||
ptr.con = conn->request_info.client_cert->serial; ptr.var = httplib_free( ptr.var );
|
||||
ptr.con = conn->request_info.client_cert->finger; ptr.var = httplib_free( ptr.var );
|
||||
conn->request_info.client_cert = httplib_free( conn->request_info.client_cert );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -181,7 +179,7 @@ static void *worker_thread_run( struct worker_thread_args *thread_args ) {
|
||||
CloseHandle( tls.pthread_cond_helper_mutex );
|
||||
#endif
|
||||
httplib_pthread_mutex_destroy( & conn->mutex );
|
||||
httplib_free( conn );
|
||||
conn = httplib_free( conn );
|
||||
|
||||
return NULL;
|
||||
|
||||
|
Reference in New Issue
Block a user