mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 10:22:46 +00:00
fix a memory leak in device state
The callback handle_statechange (pbx.c) fails to release its data pointer, leaking memory in the process. Reported by: tzafrir Patches: 18735_pbx_free_callback.diff uploaded by tzafrir (license 46) Review: https://reviewboard.asterisk.org/r/1110/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308371 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4348,9 +4348,11 @@ static int handle_statechange(void *datap)
|
|||||||
struct ao2_iterator cb_iter;
|
struct ao2_iterator cb_iter;
|
||||||
|
|
||||||
if (ao2_container_count(hintdevices) == 0) {
|
if (ao2_container_count(hintdevices) == 0) {
|
||||||
|
ast_free(sc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!(cmpdevice = ast_malloc(sizeof(*cmpdevice) + strlen(sc->dev)))) {
|
if (!(cmpdevice = ast_malloc(sizeof(*cmpdevice) + strlen(sc->dev)))) {
|
||||||
|
ast_free(sc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(cmpdevice->hintdevice, sc->dev);
|
strcpy(cmpdevice->hintdevice, sc->dev);
|
||||||
@@ -4414,6 +4416,7 @@ static int handle_statechange(void *datap)
|
|||||||
if (cmpdevice) {
|
if (cmpdevice) {
|
||||||
ast_free(cmpdevice);
|
ast_free(cmpdevice);
|
||||||
}
|
}
|
||||||
|
ast_free(sc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user