dect
/
asterisk
Archived
13
0
Fork 0

handle out-of-memory conditions in ast_frisolate() properly (reported by Slav Kenov on asterisk-dev)

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@33037 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
kpfleming 2006-06-08 16:59:44 +00:00
parent 76e25df2bc
commit d76959d3fa
1 changed files with 11 additions and 3 deletions

14
frame.c
View File

@ -328,14 +328,22 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
out = fr;
if (!(fr->mallocd & AST_MALLOCD_SRC)) {
if (fr->src)
out->src = strdup(fr->src);
if (fr->src) {
if (!(out->src = ast_strdup(fr->src))) {
if (out != fr)
free(out);
return NULL;
}
}
} else
out->src = fr->src;
if (!(fr->mallocd & AST_MALLOCD_DATA)) {
if (!(newdata = ast_malloc(fr->datalen + AST_FRIENDLY_OFFSET))) {
free(out);
if (out->src != fr->src)
free((void *) out->src);
if (out != fr)
free(out);
return NULL;
}
newdata += AST_FRIENDLY_OFFSET;