diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-06-08 16:57:23 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-06-08 16:57:23 +0000 |
commit | 7489a7e4919b98904c4428144b72e2d9203472bb (patch) | |
tree | 78e0033caee1ea9ac17692949a23c732cd3cb511 /frame.c | |
parent | 83a4d42792b5ac968f8af5090231cac698ad6585 (diff) |
handle out-of-memory conditions properly in ast_frisolate() (reported by Slav Kenov on asterisk-dev mailing list)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@33036 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rw-r--r-- | frame.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -324,15 +324,25 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr) out = fr; if (!(fr->mallocd & AST_MALLOCD_SRC)) { - if (fr->src) + if (fr->src) { out->src = strdup(fr->src); + if (!out->src) { + if (out != fr) + free(out); + ast_log(LOG_WARNING, "Out of memory\n"); + return NULL; + } + } } else out->src = fr->src; if (!(fr->mallocd & AST_MALLOCD_DATA)) { newdata = malloc(fr->datalen + AST_FRIENDLY_OFFSET); if (!newdata) { - free(out); + if (out->src != fr->src) + free((void *) out->src); + if (out != fr) + free(out); ast_log(LOG_WARNING, "Out of memory\n"); return NULL; } |