diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-24 01:27:42 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-24 01:27:42 +0000 |
commit | bc8c087a8703293fce63841dddd99c5a3535556a (patch) | |
tree | f9f2fd0acce85c7164d4999b7353caebb842ce22 /utils/muted.c | |
parent | 5c7b47eb368708855773c88b8eeac3d82863142c (diff) |
In muted.c, check the return value of strdup. In ael_main.c, check the return
value of calloc. (issue #8157)
In passing fix a few minor bugs in ael_main.c. The last argument to strncpy()
was a hard-coded 100, where it should have been 99. I changed this to use
sizeof() - 1.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46067 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils/muted.c')
-rw-r--r-- | utils/muted.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/utils/muted.c b/utils/muted.c index 6a0912fdb..37ae42c5e 100644 --- a/utils/muted.c +++ b/utils/muted.c @@ -85,8 +85,15 @@ static void add_channel(char *tech, char *location) chan = malloc(sizeof(struct channel)); if (chan) { memset(chan, 0, sizeof(struct channel)); - chan->tech = strdup(tech); - chan->location = strdup(location); + if (!(chan->tech = strdup(tech))) { + free(chan); + return; + } + if (!(chan->location = strdup(location))) { + free(chan->tech); + free(chan); + return; + } chan->next = channels; channels = chan; } @@ -550,7 +557,10 @@ static void append_sub(struct channel *chan, char *name) sub = malloc(sizeof(struct subchannel)); if (sub) { memset(sub, 0, sizeof(struct subchannel)); - sub->name = strdup(name); + if (!(sub->name = strdup(name))) { + free(sub); + return; + } sub->next = chan->subs; chan->subs = sub; } |