[Core] scan-build: memory leak in switch_xml_user_cache()

This commit is contained in:
Andrey Volk 2021-04-23 00:23:39 +03:00
parent e30c62f8ec
commit 781180ff48

View File

@ -2095,10 +2095,9 @@ static void switch_xml_user_cache(const char *key, const char *user_name, const
switch_safe_free(expires_lookup); switch_safe_free(expires_lookup);
} }
if (expires) { if (expires) {
char *expires_val = switch_must_malloc(1024); char *expires_val = (char *)switch_core_hash_insert_alloc(CACHE_EXPIRES_HASH, mega_key, 22);
if (sprintf(expires_val, "%ld", (long)expires)) { if (!snprintf(expires_val, 22, "%ld", (long)expires)) {
switch_core_hash_insert(CACHE_EXPIRES_HASH, mega_key, expires_val); switch_core_hash_delete(CACHE_EXPIRES_HASH, mega_key);
} else {
switch_safe_free(expires_val); switch_safe_free(expires_val);
} }
} }