aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcdr.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/cdr.c b/cdr.c
index bdac2fb57..9a01ec03c 100755
--- a/cdr.c
+++ b/cdr.c
@@ -147,19 +147,20 @@ void ast_cdr_unregister(char *name)
AST_LIST_UNLOCK(&be_list);
}
-static struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr)
+static struct ast_cdr *cdr_dup(struct ast_cdr *cdr)
{
- struct ast_cdr *newcdr = NULL;
+ struct ast_cdr *newcdr;
if (!(newcdr = ast_cdr_alloc())) {
ast_log(LOG_ERROR, "Memory Error!\n");
- } else {
- memcpy(newcdr,cdr,sizeof(struct ast_cdr));
- /* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
- memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
- ast_cdr_copy_vars(newcdr, cdr);
+ return NULL;
}
+ memcpy(newcdr, cdr, sizeof(*newcdr));
+ /* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
+ memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
+ ast_cdr_copy_vars(newcdr, cdr);
+
return newcdr;
}
@@ -822,7 +823,7 @@ void ast_cdr_reset(struct ast_cdr *cdr, int flags)
if (ast_test_flag(&tmp, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
if (ast_test_flag(&tmp, AST_CDR_FLAG_POSTED)) {
ast_cdr_end(cdr);
- if ((dup = ast_cdr_dup(cdr))) {
+ if ((dup = cdr_dup(cdr))) {
ast_cdr_detach(dup);
}
ast_set_flag(cdr, AST_CDR_FLAG_POSTED);