Pārlūkot izejas kodu

app_lua: safety check of returned anchor before using it

Daniel-Constantin Mierla 8 gadi atpakaļ
vecāks
revīzija
f109109a19
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  1. 6 0
      modules/app_lua/app_lua_sr.c

+ 6 - 0
modules/app_lua/app_lua_sr.c

@@ -744,6 +744,12 @@ static int lua_sr_hdr_append (lua_State *L)
 	memcpy(hdr, txt, len);
 	memcpy(hdr, txt, len);
 	anchor = anchor_lump(env_L->msg,
 	anchor = anchor_lump(env_L->msg,
 				hf->name.s + hf->len - env_L->msg->buf, 0, 0);
 				hf->name.s + hf->len - env_L->msg->buf, 0, 0);
+	if(anchor==NULL)
+	{
+		LM_ERR("unable to get the anchor\n");
+		pkg_free(hdr);
+		return 0;
+	}
 	if(insert_new_lump_before(anchor, hdr, len, 0) == 0)
 	if(insert_new_lump_before(anchor, hdr, len, 0) == 0)
 	{
 	{
 		LM_ERR("can't insert lump\n");
 		LM_ERR("can't insert lump\n");