diff options
| author | Ben Foster | 2017-10-25 23:53:07 +0100 |
|---|---|---|
| committer | Ben Foster | 2017-10-26 21:14:00 +0100 |
| commit | 1eb51a18ec06b3c8add77d876af0f5a599279c67 (patch) | |
| tree | abd9a74672c5111edf6ee6aea0f9c0dd843ca580 | |
| parent | 59b3db273e6e628afb188681e178ea53d571b03d (diff) | |
Free additionally allocated `sp_list` instances
References #43.
| -rw-r--r-- | src/snuffleupagus.c | 16 | ||||
| -rw-r--r-- | src/sp_config.c | 10 | ||||
| -rw-r--r-- | src/sp_config.h | 2 |
3 files changed, 25 insertions, 3 deletions
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index 2cc31d8..7db6c93 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #endif | 3 | #endif |
| 4 | 4 | ||
| 5 | #include "php_snuffleupagus.h" | 5 | #include "php_snuffleupagus.h" |
| 6 | #include "sp_config.h" | ||
| 6 | 7 | ||
| 7 | #ifndef ZEND_EXT_API | 8 | #ifndef ZEND_EXT_API |
| 8 | #define ZEND_EXT_API ZEND_DLEXPORT | 9 | #define ZEND_EXT_API ZEND_DLEXPORT |
| @@ -118,11 +119,20 @@ PHP_MSHUTDOWN_FUNCTION(snuffleupagus) { | |||
| 118 | pefree(SNUFFLEUPAGUS_G(config.config_upload_validation), 1); | 119 | pefree(SNUFFLEUPAGUS_G(config.config_upload_validation), 1); |
| 119 | pefree(SNUFFLEUPAGUS_G(config.config_cookie_encryption), 1); | 120 | pefree(SNUFFLEUPAGUS_G(config.config_cookie_encryption), 1); |
| 120 | 121 | ||
| 121 | sp_list_free(SNUFFLEUPAGUS_G(config.config_disabled_functions->disabled_functions)); | 122 | sp_node_t* disabled_functions = SNUFFLEUPAGUS_G(config.config_disabled_functions->disabled_functions); |
| 123 | sp_node_t* disabled_functions_ret = SNUFFLEUPAGUS_G(config.config_disabled_functions_ret->disabled_functions); | ||
| 124 | sp_node_t* disabled_constructs = SNUFFLEUPAGUS_G(config.config_disabled_constructs->construct_include); | ||
| 125 | |||
| 126 | // Free the list of disabled functions for each `sp_disabled_function` instance | ||
| 127 | sp_disabled_function_list_free(disabled_functions); | ||
| 128 | sp_disabled_function_list_free(disabled_functions_ret); | ||
| 129 | sp_disabled_function_list_free(disabled_constructs); | ||
| 130 | |||
| 131 | sp_list_free(disabled_functions); | ||
| 122 | pefree(SNUFFLEUPAGUS_G(config.config_disabled_functions), 1); | 132 | pefree(SNUFFLEUPAGUS_G(config.config_disabled_functions), 1); |
| 123 | sp_list_free(SNUFFLEUPAGUS_G(config.config_disabled_functions_ret->disabled_functions)); | 133 | sp_list_free(disabled_functions_ret); |
| 124 | pefree(SNUFFLEUPAGUS_G(config.config_disabled_functions_ret), 1); | 134 | pefree(SNUFFLEUPAGUS_G(config.config_disabled_functions_ret), 1); |
| 125 | sp_list_free(SNUFFLEUPAGUS_G(config.config_disabled_constructs->construct_include)); | 135 | sp_list_free(disabled_constructs); |
| 126 | pefree(SNUFFLEUPAGUS_G(config.config_disabled_constructs), 1); | 136 | pefree(SNUFFLEUPAGUS_G(config.config_disabled_constructs), 1); |
| 127 | 137 | ||
| 128 | UNREGISTER_INI_ENTRIES(); | 138 | UNREGISTER_INI_ENTRIES(); |
diff --git a/src/sp_config.c b/src/sp_config.c index c41b8f7..13002cc 100644 --- a/src/sp_config.c +++ b/src/sp_config.c | |||
| @@ -182,3 +182,13 @@ int sp_parse_config(const char *conf_file) { | |||
| 182 | fclose(fd); | 182 | fclose(fd); |
| 183 | return SUCCESS; | 183 | return SUCCESS; |
| 184 | } | 184 | } |
| 185 | |||
| 186 | void sp_disabled_function_list_free(sp_node_t* list) { | ||
| 187 | sp_node_t* cursor = list; | ||
| 188 | while(cursor) { | ||
| 189 | sp_disabled_function* df = cursor->data; | ||
| 190 | if (df && df->functions_list) | ||
| 191 | sp_list_free(df->functions_list); | ||
| 192 | cursor = cursor->next; | ||
| 193 | } | ||
| 194 | } | ||
diff --git a/src/sp_config.h b/src/sp_config.h index eda7517..ac33eb5 100644 --- a/src/sp_config.h +++ b/src/sp_config.h | |||
| @@ -206,5 +206,7 @@ int parse_empty(char *restrict, char *restrict, void *); | |||
| 206 | int parse_cidr(char *restrict, char *restrict, void *); | 206 | int parse_cidr(char *restrict, char *restrict, void *); |
| 207 | int parse_php_type(char *restrict, char *restrict, void *); | 207 | int parse_php_type(char *restrict, char *restrict, void *); |
| 208 | 208 | ||
| 209 | // cleanup | ||
| 210 | void sp_disabled_function_list_free(sp_node_t*); | ||
| 209 | 211 | ||
| 210 | #endif /* SP_CONFIG_H */ | 212 | #endif /* SP_CONFIG_H */ |
