Merge pull request #369 from signalwire/custom_hash_leak

[Core] Fix possible leak of the subclass variable in CUSTOM_HASH'es switch_event_reserve_subclass_detailed().
This commit is contained in:
Andrey Volk 2020-02-16 00:51:34 +04:00 committed by GitHub
commit 9f2d044ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -1338,6 +1338,12 @@ SWITCH_DECLARE(void) switch_split_time(const char *exp, int *hour, int *min, int
*/
SWITCH_DECLARE(int) switch_split_user_domain(char *in, char **user, char **domain);
SWITCH_DECLARE(void *) switch_calloc(size_t nmemb, size_t size);
#ifdef __clang_analyzer__
#define calloc switch_calloc
#endif
/* malloc or DIE macros */
#ifdef NDEBUG
#define switch_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr )

View File

@ -503,7 +503,13 @@ SWITCH_DECLARE(switch_status_t) switch_event_reserve_subclass_detailed(const cha
subclass->owner = DUP(owner);
subclass->name = DUP(subclass_name);
switch_core_hash_insert(CUSTOM_HASH, subclass->name, subclass);
status = switch_core_hash_insert(CUSTOM_HASH, subclass->name, subclass);
if (status != SWITCH_STATUS_SUCCESS) {
free(subclass->owner);
free(subclass->name);
free(subclass);
}
end:

View File

@ -71,6 +71,11 @@ struct switch_network_list {
char *name;
};
SWITCH_DECLARE(void *) switch_calloc(size_t nmemb, size_t size)
{
return calloc(nmemb, size);
}
#ifndef WIN32
SWITCH_DECLARE(int) switch_inet_pton(int af, const char *src, void *dst)
{