summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_rpt.c23
-rw-r--r--channels/chan_console.c3
-rw-r--r--channels/chan_dahdi.c2
-rw-r--r--main/astobj2.c8
-rw-r--r--main/cli.c3
5 files changed, 16 insertions, 23 deletions
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index a261fc144..14414140c 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -1957,7 +1957,11 @@ unsigned int seq;
if (!myrpt->p.statpost_url) return;
str = ast_malloc(strlen(pairs) + strlen(myrpt->p.statpost_url) + 200);
astr = ast_strdup(myrpt->p.statpost_program);
- if ((!str) || (!astr)) return;
+ if ((!str) || (!astr)) {
+ ast_free(str);
+ ast_free(astr);
+ return;
+ }
n = finddelim(astr,astrs,100);
if (n < 1) return;
ast_mutex_lock(&myrpt->statpost_lock);
@@ -2895,12 +2899,8 @@ static int rpt_do_stats(int fd, int argc, char *argv[])
for(j = 0; j < numoflinks; j++){ /* ast_free() all link names */
ast_free(listoflinks[j]);
}
- if(called_number){
- ast_free(called_number);
- }
- if(lastdtmfcommand){
- ast_free(lastdtmfcommand);
- }
+ ast_free(called_number);
+ ast_free(lastdtmfcommand);
return RESULT_SUCCESS;
}
}
@@ -3646,8 +3646,7 @@ static int send_tone_telemetry(struct ast_channel *chan, char *tonestring)
if(res)
break;
}
- if(p)
- ast_free(p);
+ ast_free(p);
if(!res)
res = play_tone_pair(chan, 0, 0, 100, 0); /* This is needed to ensure the last tone segment is timed correctly */
@@ -3828,8 +3827,7 @@ static int telem_lookup(struct rpt *myrpt,struct ast_channel *chan, char *node,
else{
res = -1;
}
- if(telemetry_save)
- ast_free(telemetry_save);
+ ast_free(telemetry_save);
return res;
}
@@ -3907,8 +3905,7 @@ static int get_wait_interval(struct rpt *myrpt, int type)
interval = 0;
break;
}
- if(wait_times_save)
- ast_free(wait_times_save);
+ ast_free(wait_times_save);
return interval;
}
diff --git a/channels/chan_console.c b/channels/chan_console.c
index 5bdfa99ba..091fcf1b1 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -838,8 +838,7 @@ static char *cli_console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_a
} else
ast_cli(a->fd, "No such extension '%s' in context '%s'\n", mye, myc);
- if (s)
- free(s);
+ free(s);
unref_pvt(pvt);
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index b3fcac294..fb255956e 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -10183,8 +10183,6 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
if (!here && reloading != 1) {
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
- if (tmp)
- free(tmp);
return NULL;
}
ast_mutex_init(&tmp->lock);
diff --git a/main/astobj2.c b/main/astobj2.c
index 13e0c54b2..91ec1428c 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -342,11 +342,11 @@ void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char
void *obj;
FILE *refo = ref_debug ? fopen(REF_FILE,"a") : NULL;
- obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname);
-
- if (obj == NULL)
+ if ((obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname)) == NULL) {
+ fclose(refo);
return NULL;
-
+ }
+
if (refo) {
fprintf(refo, "%p =1 %s:%d:%s (%s)\n", obj, file, line, funcname, tag);
fclose(refo);
diff --git a/main/cli.c b/main/cli.c
index 136d56a1e..1bfe263f0 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -235,8 +235,7 @@ static char *complete_fn(const char *word, int state)
c += (strlen(ast_config_AST_MODULE_DIR) + 1);
if (c)
c = ast_strdup(c);
- if (d)
- free(d);
+ free(d);
return c;
}