Browse code

this fixes a bug related to empty replies (empty body).

Raphael Coeffic authored on 28/09/2003 17:16:01
Showing 1 changed files
... ...
@@ -1184,15 +1184,19 @@ int t_reply_with_body( struct cell *trans, unsigned int code,
1184 1184
 	}
1185 1185
 	add_lump_rpl( trans->uas.request, hdr_lump);
1186 1186
 	/* body lump */
1187
-	body_lump = build_lump_rpl( body , strlen(body) , LUMP_RPL_BODY );
1188
-	if (body_lump==0) {
1187
+	if(body && strlen(body)) {
1188
+	    body_lump = build_lump_rpl( body , strlen(body) , LUMP_RPL_BODY );
1189
+	    if (body_lump==0) {
1189 1190
 		LOG(L_ERR,"ERROR:tm:t_reply_with_body: cannot create body lump\n");
1190 1191
 		goto error_1;
1191
-	}
1192
-	if (add_lump_rpl( trans->uas.request, body_lump)==-1) {
1192
+	    }
1193
+	    if (add_lump_rpl( trans->uas.request, body_lump)==-1) {
1193 1194
 		LOG(L_ERR,"ERROR:tm:t_reply_with_body: cannot add body lump\n");
1194 1195
 		goto error_1;
1196
+	    }
1195 1197
 	}
1198
+	else
1199
+	    body_lump = 0;
1196 1200
 
1197 1201
 	rpl.s = build_res_buf_from_sip_req(
1198 1202
 			code, text, &s_to_tag,
... ...
@@ -1202,9 +1206,11 @@ int t_reply_with_body( struct cell *trans, unsigned int code,
1202 1206
 	 * memory leak or crashing (lumps are create in private memory) I will
1203 1207
 	 * remove the lumps by myself here (bogdan) */
1204 1208
 	unlink_lump_rpl( trans->uas.request, hdr_lump);
1205
-	unlink_lump_rpl( trans->uas.request, body_lump);
1206 1209
 	pkg_free( hdr_lump );
1207
-	pkg_free( body_lump );
1210
+	if( body_lump ) {
1211
+	    unlink_lump_rpl( trans->uas.request, body_lump);
1212
+	    pkg_free( body_lump );
1213
+	}
1208 1214
 
1209 1215
 	if (rpl.s==0) {
1210 1216
 		LOG(L_ERR,"ERROR:tm:t_reply_with_body: failed in doing "