From: Kevin P. Fleming Date: Thu, 8 Jun 2006 16:57:23 +0000 (+0000) Subject: handle out-of-memory conditions properly in ast_frisolate() (reported by Slav Kenov... X-Git-Tag: 1.2.10~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a19de52a1e29afb93560a63e993d43ae7f1d1217;p=thirdparty%2Fasterisk.git handle out-of-memory conditions properly in ast_frisolate() (reported by Slav Kenov on asterisk-dev mailing list) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@33036 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/frame.c b/frame.c index a43a9834d7..d2fc71cb18 100644 --- a/frame.c +++ b/frame.c @@ -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; }