Browse code

tmx: check for empty result not to allocate 0 bytes

- allocation of 0 size is undefined when using system malloc

(cherry picked from commit 0db313f0047fc512dec2976cac168989b60d49c8)

Daniel-Constantin Mierla authored on 14/05/2015 11:24:38
Showing 1 changed files
... ...
@@ -233,6 +233,10 @@ static inline char *get_hfblock( str *uri, struct hdr_field *hf, int *l, struct
233 233
 		LM_DBG("one more hf processed\n");
234 234
 	} /* header loop */
235 235
 
236
+	if(total_len==0) {
237
+		LM_DBG("empty result\n");
238
+		goto error;
239
+	}
236 240
 
237 241
 	/* construct a single header block now */
238 242
 	ret=pkg_malloc(total_len);