Blob Blame History Raw
From: Vlad Patrascu <vladp@opensips.org>
Date: Thu, 14 Jun 2018 19:47:33 +0300
Subject: [PATCH] Handle oom when allocating message body in add_body_part()

(cherry picked from commit 844dbcb2bc0c53e0b61554e740bff7034243eac6)

diff --git a/parser/parse_body.c b/parser/parse_body.c
index bf412bd15..e74cf92e6 100644
--- a/parser/parse_body.c
+++ b/parser/parse_body.c
@@ -319,6 +319,10 @@ struct body_part* add_body_part(struct sip_msg *msg, str *mime_s, str *body)
 		/* the message has no body so far */
 		msg->body = (struct sip_msg_body*)pkg_malloc(
 			sizeof(struct sip_msg_body) + (body?body->len:0) + mime_s->len );
+		if (!msg->body) {
+			LM_ERR("No more pkg memory!\n");
+			return NULL;
+		}
 		memset(msg->body, 0, sizeof(struct sip_msg_body));
 
 		msg->body->part_count = 0;