Browse code

tm: safety check not to allocate 0 bytes in rpc command

(cherry picked from commit 88b67575f9457312d0277e16dc06103be3a31965)

Daniel-Constantin Mierla authored on 14/05/2015 11:40:11
Showing 1 changed files
... ...
@@ -218,7 +218,12 @@ static char *get_hfblock(str *uri, struct hdr_field *hf, int proto,
218 218
 		DBG("get_hfblock: one more hf processed\n");
219 219
 	} /* header loop */
220 220
 	
221
-	     /* construct a single header block now */
221
+	if(total_len==0) {
222
+		LM_DBG("empty result for headers block\n");
223
+		goto error;
224
+	}
225
+
226
+	/* construct a single header block now */
222 227
 	ret = pkg_malloc(total_len);
223 228
 	if (!ret) {
224 229
 		LOG(L_ERR, "get_hfblock: no pkg mem for hf block\n");