[asterisk-commits] branch 1.2 r33036 - /branches/1.2/frame.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Jun 8 09:57:24 MST 2006
Author: kpfleming
Date: Thu Jun 8 11:57:23 2006
New Revision: 33036
URL: http://svn.digium.com/view/asterisk?rev=33036&view=rev
Log:
handle out-of-memory conditions properly in ast_frisolate() (reported by Slav Kenov on asterisk-dev mailing list)
Modified:
branches/1.2/frame.c
Modified: branches/1.2/frame.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/frame.c?rev=33036&r1=33035&r2=33036&view=diff
==============================================================================
--- branches/1.2/frame.c (original)
+++ branches/1.2/frame.c Thu Jun 8 11:57:23 2006
@@ -324,15 +324,25 @@
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;
}
More information about the asterisk-commits
mailing list