mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-14 20:29:17 +00:00
FS-3535 --resolve fix memory leak in mod_lcr
This commit is contained in:
parent
3317f5d36d
commit
f308f56c71
@ -605,6 +605,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
switch_bool_t lcr_skipped = SWITCH_TRUE; /* assume we'll throw it away, paranoid about leak */
|
||||||
|
|
||||||
switch_memory_pool_t *pool = cbt->pool;
|
switch_memory_pool_t *pool = cbt->pool;
|
||||||
|
|
||||||
@ -669,6 +670,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||||
r = -1; goto end;
|
r = -1; goto end;
|
||||||
}
|
}
|
||||||
|
lcr_skipped = SWITCH_FALSE;
|
||||||
r = 0; goto end;
|
r = 0; goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,6 +700,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||||
r = -1; goto end;
|
r = -1; goto end;
|
||||||
}
|
}
|
||||||
|
lcr_skipped = SWITCH_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -719,6 +722,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||||
r = -1; goto end;
|
r = -1; goto end;
|
||||||
}
|
}
|
||||||
|
lcr_skipped = SWITCH_FALSE;
|
||||||
break;
|
break;
|
||||||
} else if (current->next == NULL) {
|
} else if (current->next == NULL) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s to end of list after %s\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s to end of list after %s\n",
|
||||||
@ -729,6 +733,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||||
r = -1; goto end;
|
r = -1; goto end;
|
||||||
}
|
}
|
||||||
|
lcr_skipped = SWITCH_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -736,7 +741,12 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
/* event is freed in lcr_destroy() switch_event_destroy(&additional->fields); */
|
/* lcr was not added to any lists, so destroy lcr object here */
|
||||||
|
if (lcr_skipped == SWITCH_TRUE) {
|
||||||
|
/* ensure we didn't accidentally add additional to the list */
|
||||||
|
switch_assert(additional->prev == NULL && current->next != additional);
|
||||||
|
lcr_destroy(additional);
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user