automerge commit

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@25200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Automerge script
2006-05-06 03:06:16 +00:00
parent 034337fb07
commit 91096b7368

18
frame.c
View File

@@ -304,6 +304,8 @@ void ast_frfree(struct ast_frame *fr)
struct ast_frame *ast_frisolate(struct ast_frame *fr) struct ast_frame *ast_frisolate(struct ast_frame *fr)
{ {
struct ast_frame *out; struct ast_frame *out;
void *newdata;
if (!(fr->mallocd & AST_MALLOCD_HDR)) { if (!(fr->mallocd & AST_MALLOCD_HDR)) {
/* Allocate a new header if needed */ /* Allocate a new header if needed */
out = ast_frame_header_new(); out = ast_frame_header_new();
@@ -318,27 +320,31 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
out->offset = fr->offset; out->offset = fr->offset;
out->src = NULL; out->src = NULL;
out->data = fr->data; out->data = fr->data;
} else { } else
out = fr; out = fr;
}
if (!(fr->mallocd & AST_MALLOCD_SRC)) { if (!(fr->mallocd & AST_MALLOCD_SRC)) {
if (fr->src) if (fr->src)
out->src = strdup(fr->src); out->src = strdup(fr->src);
} else } else
out->src = fr->src; out->src = fr->src;
if (!(fr->mallocd & AST_MALLOCD_DATA)) { if (!(fr->mallocd & AST_MALLOCD_DATA)) {
out->data = malloc(fr->datalen + AST_FRIENDLY_OFFSET); newdata = malloc(fr->datalen + AST_FRIENDLY_OFFSET);
if (!out->data) { if (!newdata) {
free(out); free(out);
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
return NULL; return NULL;
} }
out->data += AST_FRIENDLY_OFFSET; newdata += AST_FRIENDLY_OFFSET;
out->offset = AST_FRIENDLY_OFFSET; out->offset = AST_FRIENDLY_OFFSET;
out->datalen = fr->datalen; out->datalen = fr->datalen;
memcpy(out->data, fr->data, fr->datalen); memcpy(newdata, fr->data, fr->datalen);
out->data = newdata;
} }
out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA; out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA;
return out; return out;
} }