Explorar el Código

ims_ipsec_pcscf: free memory on errors and variable supported

Daniel-Constantin Mierla hace 7 años
padre
commit
82f7a6a7f5
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      src/modules/ims_ipsec_pcscf/cmd.c

+ 4 - 0
src/modules/ims_ipsec_pcscf/cmd.c

@@ -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;
 }