mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-03 20:38:59 +00:00 
			
		
		
		
	Fix reset cdr (bug #4531)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5920 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										23
									
								
								cdr.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								cdr.c
									
									
									
									
									
								
							@@ -147,6 +147,22 @@ void ast_cdr_unregister(char *name)
 | 
			
		||||
	AST_LIST_UNLOCK(&be_list);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr) 
 | 
			
		||||
{
 | 
			
		||||
	struct ast_cdr *newcdr = NULL;
 | 
			
		||||
 | 
			
		||||
	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 newcdr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *ast_cdr_getvar_internal(struct ast_cdr *cdr, const char *name, int recur) 
 | 
			
		||||
{
 | 
			
		||||
	struct ast_var_t *variables;
 | 
			
		||||
@@ -800,14 +816,15 @@ void ast_cdr_reset(struct ast_cdr *cdr, int flags)
 | 
			
		||||
	struct ast_flags tmp = {flags};
 | 
			
		||||
	struct ast_cdr *dup;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	while (cdr) {
 | 
			
		||||
		/* Detach if post is requested */
 | 
			
		||||
		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);
 | 
			
		||||
				dup = ast_cdr_alloc();
 | 
			
		||||
				memcpy(dup, cdr, sizeof(*dup));
 | 
			
		||||
				ast_cdr_detach(dup);
 | 
			
		||||
				if ((dup = ast_cdr_dup(cdr))) {
 | 
			
		||||
					ast_cdr_detach(dup);
 | 
			
		||||
				}
 | 
			
		||||
				ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user