aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-03-31 20:12:34 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-03-31 20:12:34 +0000
commit3c6a00707874deab799e7192bdc4bc74eb3a4c06 (patch)
tree3677fcbf0b3b0b3263e138cdeda54d03ed84d57d /channels
parent6dee061e6e0e7ccb31dce22eb281ce217ac4ce5f (diff)
Merged revisions 312022 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r312022 | rmudgett | 2011-03-31 15:11:40 -0500 (Thu, 31 Mar 2011) | 14 lines chan_misdn segfaults when DEBUG_THREADS is enabled. The segfault happens because jb->mutexjb is uninitialized from the ast_malloc(). The internals of ast_mutex_init() were assuming a nonzero value meant mutex tracking initialization had already happened. Recent changes to mutex tracking code to reduce excessive memory consumption exposed this uninitialized value. Converted misdn_jb_init() to use ast_calloc() instead of ast_malloc(). Also eliminated redundant zero initialization code in the routine. (closes issue #18975) Reported by: irroot ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@312023 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_misdn.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 91ee823a9..194229723 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -12453,29 +12453,28 @@ int chan_misdn_jb_empty(struct misdn_bchannel *bc, char *buf, int len)
/* allocates the jb-structure and initialize the elements*/
struct misdn_jb *misdn_jb_init(int size, int upper_threshold)
{
- int i;
struct misdn_jb *jb;
- jb = ast_malloc(sizeof(*jb));
+ jb = ast_calloc(1, sizeof(*jb));
if (!jb) {
chan_misdn_log(-1, 0, "No free Mem for jb\n");
return NULL;
}
jb->size = size;
jb->upper_threshold = upper_threshold;
- jb->wp = 0;
- jb->rp = 0;
- jb->state_full = 0;
- jb->state_empty = 0;
- jb->bytes_wrote = 0;
- jb->samples = ast_malloc(size * sizeof(char));
+ //jb->wp = 0;
+ //jb->rp = 0;
+ //jb->state_full = 0;
+ //jb->state_empty = 0;
+ //jb->bytes_wrote = 0;
+ jb->samples = ast_calloc(size, sizeof(*jb->samples));
if (!jb->samples) {
ast_free(jb);
chan_misdn_log(-1, 0, "No free Mem for jb->samples\n");
return NULL;
}
- jb->ok = ast_malloc(size * sizeof(char));
+ jb->ok = ast_calloc(size, sizeof(*jb->ok));
if (!jb->ok) {
ast_free(jb->samples);
ast_free(jb);
@@ -12483,10 +12482,6 @@ struct misdn_jb *misdn_jb_init(int size, int upper_threshold)
return NULL;
}
- for (i = 0; i < size; i++) {
- jb->ok[i] = 0;
- }
-
ast_mutex_init(&jb->mutexjb);
return jb;