瀏覽代碼

tmx: check for empty result not to allocate 0 bytes

- allocation of 0 size is undefined when using system malloc
Daniel-Constantin Mierla 10 年之前
父節點
當前提交
0db313f004
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      modules/tmx/t_mi.c

+ 4 - 0
modules/tmx/t_mi.c

@@ -228,6 +228,10 @@ static inline char *get_hfblock( str *uri, struct hdr_field *hf, int *l, struct
 		LM_DBG("one more hf processed\n");
 		LM_DBG("one more hf processed\n");
 	} /* header loop */
 	} /* header loop */
 
 
+	if(total_len==0) {
+		LM_DBG("empty result\n");
+		goto error;
+	}
 
 
 	/* construct a single header block now */
 	/* construct a single header block now */
 	ret=pkg_malloc(total_len);
 	ret=pkg_malloc(total_len);