From: Sean Bright Date: Wed, 13 Sep 2017 19:14:25 +0000 (-0400) Subject: res_calendar: Plug memory leak and micro-optimization X-Git-Tag: 16.0.0-rc1~809^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=55567ee1d893b353906a3d1406d85ee9e904e415;p=thirdparty%2Fasterisk.git res_calendar: Plug memory leak and micro-optimization ast_variables_destroy is NULL safe, so there is no need to check its argument before passing it. ASTERISK-25524 #close Reported by: Jesper Change-Id: Ib0f8057642e9d471960f1a79fd42e5a3ce587d3b --- diff --git a/res/res_calendar.c b/res/res_calendar.c index bf385dba69..3369f38cef 100644 --- a/res/res_calendar.c +++ b/res/res_calendar.c @@ -339,10 +339,7 @@ static void calendar_destructor(void *obj) } ast_calendar_clear_events(cal); ast_string_field_free_memory(cal); - if (cal->vars) { - ast_variables_destroy(cal->vars); - cal->vars = NULL; - } + ast_variables_destroy(cal->vars); ao2_ref(cal->events, -1); ao2_unlock(cal); } diff --git a/res/res_calendar_caldav.c b/res/res_calendar_caldav.c index b6822b0854..248c80e654 100644 --- a/res/res_calendar_caldav.c +++ b/res/res_calendar_caldav.c @@ -78,6 +78,7 @@ static void caldav_destructor(void *obj) if (pvt->session) { ne_session_destroy(pvt->session); } + ne_uri_free(&pvt->uri); ast_string_field_free_memory(pvt); ao2_callback(pvt->events, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL);