ims_ipsec_pcscf: free memory on errors and variable supported
authorDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 19 Oct 2018 07:36:00 +0000 (09:36 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 19 Oct 2018 07:36:00 +0000 (09:36 +0200)
src/modules/ims_ipsec_pcscf/cmd.c

index e0eeea8..17e6c7b 100644 (file)
@@ -357,15 +357,19 @@ int add_supported_secagree_header(struct sip_msg* m)
 
     if((supported->s = pkg_malloc(supported_sec_agree_len)) == NULL) {
         LM_ERR("Error allcationg pkg memory for supported header str\n");
+        pkg_free(supported);
         return -1;
     }
     memcpy(supported->s, supported_sec_agree, supported_sec_agree_len);
     supported->len = supported_sec_agree_len;
 
     if(cscf_add_header(m, supported, HDR_SUPPORTED_T) != 1) {
+               pkg_free(supported->s);
+               pkg_free(supported);
         LM_ERR("Error adding security header to reply!\n");
         return -1;
     }
+    pkg_free(supported);
 
     return 0;
 }