parser: switch pkg_free(tob) to free_to(tob) to free To header structure
authorDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 19 Sep 2011 11:29:44 +0000 (13:29 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 19 Sep 2011 11:29:44 +0000 (13:29 +0200)
- this takes care of freeing parameters in case of paring error of
  To-like headers
- patch by Walter Doekes, closes FS#155

lib/kcore/parse_pai.c
lib/kcore/parse_ppi.c
modules/sanity/sanity.c
modules_k/seas/encode_header.c
parser/msg_parser.c
parser/parse_diversion.c
parser/parse_from.c
parser/parse_refer_to.c
parser/parse_rpid.c

index 5cd580f..d0dda3d 100644 (file)
@@ -66,7 +66,7 @@ int parse_pai_header( struct sip_msg *msg )
        parse_to(msg->pai->body.s, msg->pai->body.s + msg->pai->body.len+1, pai_b);
        if (pai_b->error == PARSE_ERROR) {
                LM_ERR("bad P-Asserted-Identity header\n");
-               pkg_free(pai_b);
+               free_to(pai_b);
                goto error;
        }
        msg->pai->parsed = pai_b;
index 5857709..4dc9ec8 100644 (file)
@@ -74,7 +74,7 @@ int parse_ppi_header( struct sip_msg *msg )
             ppi_b);
     if (ppi_b->error == PARSE_ERROR) {
        LM_ERR("bad P-Preferred-Identity header\n");
-       pkg_free(ppi_b);
+       free_to(ppi_b);
        goto error;
     }
        msg->ppi->parsed = ppi_b;
index e60a28c..fe6585a 100644 (file)
@@ -756,7 +756,7 @@ int check_parse_uris(struct sip_msg* _msg, int checks) {
                                LOG(L_WARN, "sanity_check(): check_parse_uris():"
                                                " failed to parse From header [%.*s]\n",
                                                _msg->from->body.len, _msg->from->body.s);
-                               pkg_free(ft_body);
+                               free_to(ft_body);
                                if (_msg->REQ_METHOD != METHOD_ACK) {
                                        if (slb.zreply(_msg, 400, "Bad From header") < 0) {
                                                LOG(L_WARN, "sanity_check(): check_parse_uris():"
index 0f7e532..549558c 100644 (file)
@@ -139,7 +139,7 @@ int encode_header(struct sip_msg *sipmsg,struct hdr_field *hdr,unsigned char *pa
            parse_to(hdr->body.s,hdr->body.s+hdr->body.len+1,tobody);
            if (tobody->error == PARSE_ERROR) {
               myerror="bad (REFER,TO,FROM,RPID) header\n";
-              pkg_free(tobody);
+              free_to(tobody);
               return 5;
               goto error;
            }
index 705c5fb..73a86cf 100644 (file)
@@ -156,7 +156,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
                        tmp=parse_cseq(tmp, end, cseq_b);
                        if (cseq_b->error==PARSE_ERROR){
                                LOG(L_ERR, "ERROR: get_hdr_field: bad cseq\n");
-                               pkg_free(cseq_b);
+                               free_cseq(cseq_b);
                                goto error;
                        }
                        hdr->parsed=cseq_b;
@@ -177,7 +177,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
                        tmp=parse_to(tmp, end,to_b);
                        if (to_b->error==PARSE_ERROR){
                                LOG(L_ERR, "ERROR: get_hdr_field: bad to header\n");
-                               pkg_free(to_b);
+                               free_to(to_b);
                                goto error;
                        }
                        hdr->parsed=to_b;
index e34d9bc..8f07f53 100644 (file)
@@ -69,7 +69,7 @@ int parse_diversion_header(struct sip_msg *msg)
        parse_to(msg->diversion->body.s, msg->diversion->body.s + msg->diversion->body.len + 1, diversion_b);
        if (diversion_b->error == PARSE_ERROR) {
                LOG(L_ERR, "ERROR:parse_diversion_header: bad diversion header\n");
-               pkg_free(diversion_b);
+               free_to(diversion_b);
                goto error;
        }
        msg->diversion->parsed = diversion_b;
index c33f391..79c831f 100644 (file)
@@ -77,7 +77,7 @@ int parse_from_header( struct sip_msg *msg)
        parse_to(msg->from->body.s,msg->from->body.s+msg->from->body.len+1,from_b);
        if (from_b->error == PARSE_ERROR) {
                LOG(L_ERR, "ERROR:parse_from_header: bad from header\n");
-               pkg_free(from_b);
+               free_to(from_b);
                goto error;
        }
        msg->from->parsed = from_b;
index 3ccb4a7..dc5bd29 100644 (file)
@@ -69,7 +69,7 @@ int parse_refer_to_header( struct sip_msg *msg )
                 refer_to_b);
        if (refer_to_b->error == PARSE_ERROR) {
                LOG(L_ERR, "ERROR:parse_refer_to_header: bad Refer-To header\n");
-               pkg_free(refer_to_b);
+               free_to(refer_to_b);
                goto error;
        }
        msg->refer_to->parsed = refer_to_b;
index d947932..618bdd1 100644 (file)
@@ -66,7 +66,7 @@ int parse_rpid_header( struct sip_msg *msg )
        parse_to(msg->rpid->body.s,msg->rpid->body.s+msg->rpid->body.len+1,rpid_b);
        if (rpid_b->error == PARSE_ERROR) {
                LOG(L_ERR, "ERROR:parse_rpid_header: bad rpid header\n");
-               pkg_free(rpid_b);
+               free_to(rpid_b);
                goto error;
        }
        msg->rpid->parsed = rpid_b;