From 59b605ec129d737c201847e6869c160f927aef2e Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 3 May 2002 15:04:56 +0000 Subject: [PATCH] Memory leaks. Lots of little ones. svn path=/trunk/httpp/; revision=3275 --- src/config.c | 13 +++++++++++-- src/connection.c | 5 ++++- src/format_vorbis.c | 4 ++++ src/httpp/httpp.c | 8 +++++++- src/httpp/httpp.h | 1 + src/stats.c | 1 + 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index e65a76fc..b2042e06 100644 --- a/src/config.c +++ b/src/config.c @@ -48,8 +48,9 @@ void config_initialize(void) void config_shutdown(void) { - if (_config_filename) free(_config_filename); + ice_config_dir_t *dirnode, *nextdirnode; + if (_config_filename) free(_config_filename); if (_configuration.location) free(_configuration.location); if (_configuration.admin) free(_configuration.admin); if (_configuration.source_password) free(_configuration.source_password); @@ -58,8 +59,16 @@ void config_shutdown(void) if (_configuration.log_dir) free(_configuration.log_dir); if (_configuration.access_log) free(_configuration.access_log); if (_configuration.error_log) free(_configuration.error_log); + if (_configuration.bind_address) free(_configuration.bind_address); + dirnode = _configuration.dir_list; + while(dirnode) { + nextdirnode = dirnode->next; + free(dirnode->host); + free(dirnode); + dirnode = nextdirnode; + } - memset(&_configuration, 0, sizeof(ice_config_t)); + memset(&_configuration, 0, sizeof(ice_config_t)); } int config_parse_file(const char *filename) diff --git a/src/connection.c b/src/connection.c index 87795d03..4eb7f010 100644 --- a/src/connection.c +++ b/src/connection.c @@ -386,12 +386,16 @@ static void *_handle_connection(void *arg) format_type_t format = format_get_type(contenttype); if (format < 0) { WARN1("Content-type \"%s\" not supported, dropping source", contenttype); + connection_close(con); + httpp_destroy(parser); continue; } else { source = source_create(con, parser, httpp_getvar(parser, HTTPP_VAR_URI), format); } } else { WARN0("No content-type header, cannot handle source"); + connection_close(con); + httpp_destroy(parser); continue; } @@ -400,7 +404,6 @@ static void *_handle_connection(void *arg) sock_set_blocking(con->sock, SOCK_NONBLOCK); thread_create("Source Thread", source_main, (void *)source, THREAD_DETACHED); - continue; } else if (parser->req_type == httpp_req_stats) { printf("DEBUG: stats connection...\n"); diff --git a/src/format_vorbis.c b/src/format_vorbis.c index 91438b01..12a5f803 100644 --- a/src/format_vorbis.c +++ b/src/format_vorbis.c @@ -117,6 +117,10 @@ int format_vorbis_get_buffer(format_plugin_t *self, char *data, unsigned long le state->headbuf[i] = NULL; } } + /* Clear old stuff. Rarely but occasionally needed. */ + ogg_stream_clear(&state->os); + vorbis_comment_clear(&state->vc); + vorbis_info_clear(&state->vi); state->serialno = ogg_page_serialno(&state->og); ogg_stream_init(&state->os, state->serialno); diff --git a/src/httpp/httpp.c b/src/httpp/httpp.c index b823046a..aeb93469 100644 --- a/src/httpp/httpp.c +++ b/src/httpp/httpp.c @@ -268,7 +268,7 @@ char *httpp_getvar(http_parser_t *parser, char *name) return NULL; } -void httpp_destroy(http_parser_t *parser) +void httpp_clear(http_parser_t *parser) { parser->req_type = httpp_req_none; if (parser->uri) @@ -278,6 +278,12 @@ void httpp_destroy(http_parser_t *parser) parser->vars = NULL; } +void httpp_destroy(http_parser_t *parser) +{ + httpp_clear(parser); + free(parser); +} + char *_lowercase(char *str) { long i; diff --git a/src/httpp/httpp.h b/src/httpp/httpp.h index a7bddce0..7e03f324 100644 --- a/src/httpp/httpp.h +++ b/src/httpp/httpp.h @@ -40,6 +40,7 @@ int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len); void httpp_setvar(http_parser_t *parser, char *name, char *value); char *httpp_getvar(http_parser_t *parser, char *name); void httpp_destroy(http_parser_t *parser); +void httpp_clear(http_parser_t *parser); #endif diff --git a/src/stats.c b/src/stats.c index a3138362..54408123 100644 --- a/src/stats.c +++ b/src/stats.c @@ -814,6 +814,7 @@ static int _free_source_stats(void *key) stats_source_t *node = (stats_source_t *)key; avl_tree_free(node->stats_tree, _free_stats); free(node->source); + free(node); return 1; }