From 64aebc31ed8edbc0b96c3cf2781cac445bb40905 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 3 Jun 2020 08:58:35 +0800 Subject: [PATCH] [core] fix memeory leak when font not found --- src/switch_core_video.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 6a9351cdaa..2f7b07d4bd 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -1897,6 +1897,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_create(switch_img_txt_hand if (switch_file_exists(new_handle->font_family, new_handle->pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Font %s does not exist\n", new_handle->font_family); +#if SWITCH_HAVE_FREETYPE + if (new_handle->library) { + FT_Done_FreeType(new_handle->library); + new_handle->library = NULL; + } +#endif if (free_pool) { switch_core_destroy_memory_pool(&pool); }