[svn-commits] rmudgett: branch 1.8 r312022 - /branches/1.8/channels/chan_misdn.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Mar 31 15:11:46 CDT 2011
Author: rmudgett
Date: Thu Mar 31 15:11:40 2011
New Revision: 312022
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=312022
Log:
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
Modified:
branches/1.8/channels/chan_misdn.c
Modified: branches/1.8/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_misdn.c?view=diff&rev=312022&r1=312021&r2=312022
==============================================================================
--- branches/1.8/channels/chan_misdn.c (original)
+++ branches/1.8/channels/chan_misdn.c Thu Mar 31 15:11:40 2011
@@ -12432,38 +12432,33 @@
/* 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);
chan_misdn_log(-1, 0, "No free Mem for jb->ok\n");
return NULL;
- }
-
- for (i = 0; i < size; i++) {
- jb->ok[i] = 0;
}
ast_mutex_init(&jb->mutexjb);
More information about the svn-commits
mailing list