From: Kevin P. Fleming Date: Thu, 8 Jun 2006 16:59:44 +0000 (+0000) Subject: handle out-of-memory conditions in ast_frisolate() properly (reported by Slav Kenov... X-Git-Tag: 1.4.0-beta1~984 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4702320f5439cdcc2d59469e55ddb2aa6b47a25e;p=thirdparty%2Fasterisk.git handle out-of-memory conditions in ast_frisolate() properly (reported by Slav Kenov on asterisk-dev) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@33037 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/frame.c b/frame.c index cfa7be6117..d0df4db7ea 100644 --- a/frame.c +++ b/frame.c @@ -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;