]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core, mod_cidlookup] Free memory allocated via strdup
authoryois615 <38441801+yois615@users.noreply.github.com>
Mon, 27 Mar 2023 22:47:23 +0000 (18:47 -0400)
committerGitHub <noreply@github.com>
Mon, 27 Mar 2023 22:47:23 +0000 (01:47 +0300)
In mod_cidlookup and several other modules, config parameters
are read from external XML files using the SWITCH_CONFIG_ITEM_STRING_STRDUP
method.  These items do not have string_options, and are not freed
with switch_xml_config_cleanup.  We therefore need to call switch_safe_free
for config without string_options.  We also add switch_xml_config_cleanup
to mod_cidlookup.  There are other modules that may be affected but this
commit makes no attempt at fixing those.

Fixes #1752

src/mod/applications/mod_cidlookup/mod_cidlookup.c
src/switch_xml_config.c

index 7df22fb3ef2d1b5800ecef59bddf9c0a6375285f..55d7aa0d902175602a741b2b98cc9dbe8d9b93ea 100644 (file)
@@ -845,6 +845,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load)
   Macro expands to: switch_status_t mod_cidlookup_shutdown() */
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cidlookup_shutdown)
 {
+       switch_xml_config_cleanup(instructions);
        switch_event_unbind(&reload_xml_event);
        return SWITCH_STATUS_SUCCESS;
 }
index 6d67ccdad4002a409bc113ad30e0227a9e5b32f0..a208a6168ebfc41767f6b73e832bc21ccd5ba7ec 100644 (file)
@@ -457,7 +457,7 @@ SWITCH_DECLARE(void) switch_xml_config_cleanup(switch_xml_config_item_t *instruc
                                char **ptr = (char **) item->ptr;
                                switch_xml_config_string_options_t *string_options = (switch_xml_config_string_options_t *) item->data;
                                /* if (using_strdup) */
-                               if (string_options && !string_options->pool && !string_options->length) {
+                               if (!string_options || (!string_options->pool && !string_options->length)) {
                                        switch_safe_free(*ptr);
                                }
                        }