Browse code

app_lua: safety check of returned anchor before using it

(cherry picked from commit f109109a194abcc105f6d6a2e398d28e21870941)

Daniel-Constantin Mierla authored on 04/11/2016 08:49:50
Showing 1 changed files
... ...
@@ -742,6 +742,12 @@ static int lua_sr_hdr_append (lua_State *L)
742 742
 	memcpy(hdr, txt, len);
743 743
 	anchor = anchor_lump(env_L->msg,
744 744
 				hf->name.s + hf->len - env_L->msg->buf, 0, 0);
745
+	if(anchor==NULL)
746
+	{
747
+		LM_ERR("unable to get the anchor\n");
748
+		pkg_free(hdr);
749
+		return 0;
750
+	}
745 751
 	if(insert_new_lump_before(anchor, hdr, len, 0) == 0)
746 752
 	{
747 753
 		LM_ERR("can't insert lump\n");