Skip to content
Snippets Groups Projects
Commit f8245909 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

misc: add missing free and avoid memory leaks

Change-Id: I6cb59c613702348b33b537cf29680d6359b18d4d
parent e5b55322
No related branches found
No related tags found
No related merge requests found
From 753c3c04da7465622d6f0ce2efebdf428fba536f Mon Sep 17 00:00:00 2001 pjnath/src/pjnath/ice_session.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From: jrun <darwinskernel@gmail.com> 1 file changed, 176 insertions(+)
Date: Thu, 27 Feb 2020 11:34:40 -0500
Subject: [PATCH 2/9] rfc2466
---
pjnath/src/pjnath/ice_session.c | 170 ++++++++++++++++++++++++++++++++
1 file changed, 170 insertions(+)
diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c
index 960c55156..a50c21c94 100644 index 2a4125bc5..542acf7b4 100644
--- a/pjnath/src/pjnath/ice_session.c --- a/pjnath/src/pjnath/ice_session.c
+++ b/pjnath/src/pjnath/ice_session.c +++ b/pjnath/src/pjnath/ice_session.c
@@ -30,6 +30,21 @@ @@ -29,6 +29,21 @@
#include <pj/rand.h> #include <pj/rand.h>
#include <pj/string.h> #include <pj/string.h>
...@@ -33,7 +27,7 @@ index 960c55156..a50c21c94 100644 ...@@ -33,7 +27,7 @@ index 960c55156..a50c21c94 100644
/* String names for candidate types */ /* String names for candidate types */
static const char *cand_type_names[] = static const char *cand_type_names[] =
{ {
@@ -712,6 +727,138 @@ static pj_uint32_t CALC_CAND_PRIO(pj_ice_sess *ice, @@ -703,6 +718,144 @@ static pj_uint32_t CALC_CAND_PRIO(pj_ice_sess *ice,
#endif #endif
} }
...@@ -97,6 +91,7 @@ index 960c55156..a50c21c94 100644 ...@@ -97,6 +91,7 @@ index 960c55156..a50c21c94 100644
+ rtn = recv(fd, read_buffer, pagesize, 0); + rtn = recv(fd, read_buffer, pagesize, 0);
+ if(rtn < 0) { + if(rtn < 0) {
+ perror ("recv(): "); + perror ("recv(): ");
+ free(deprecatedAddrs);
+ return; + return;
+ } + }
+ +
...@@ -105,6 +100,7 @@ index 960c55156..a50c21c94 100644 ...@@ -105,6 +100,7 @@ index 960c55156..a50c21c94 100644
+ +
+ if (nlmsg_len < sizeof (struct nlmsghdr)) { + if (nlmsg_len < sizeof (struct nlmsghdr)) {
+ perror ("Received an uncomplete netlink packet"); + perror ("Received an uncomplete netlink packet");
+ free(deprecatedAddrs);
+ return; + return;
+ } + }
+ +
...@@ -137,6 +133,7 @@ index 960c55156..a50c21c94 100644 ...@@ -137,6 +133,7 @@ index 960c55156..a50c21c94 100644
+ (idx + 256)*sizeof(char)*PJ_INET6_ADDRSTRLEN); + (idx + 256)*sizeof(char)*PJ_INET6_ADDRSTRLEN);
+ if (newDeprecated == NULL) { + if (newDeprecated == NULL) {
+ perror("realloc error: abort"); + perror("realloc error: abort");
+ free(deprecatedAddrs);
+ return; + return;
+ } + }
+ deprecatedAddrs = newDeprecated; + deprecatedAddrs = newDeprecated;
...@@ -165,16 +162,19 @@ index 960c55156..a50c21c94 100644 ...@@ -165,16 +162,19 @@ index 960c55156..a50c21c94 100644
+ *addresses = final; + *addresses = final;
+ } else { + } else {
+ perror("realloc error: abort"); + perror("realloc error: abort");
+ free(deprecatedAddrs);
+ } + }
+ } else {
+ free(deprecatedAddrs);
+ } + }
+#endif +#endif
+} +}
/* /*
* Add ICE candidate * Add ICE candidate
@@ -729,6 +876,29 @@ PJ_DEF(pj_status_t) pj_ice_sess_add_cand(pj_ice_sess *ice, @@ -719,6 +872,29 @@ PJ_DEF(pj_status_t) pj_ice_sess_add_cand(pj_ice_sess *ice,
unsigned *p_cand_id, int addr_len,
pj_ice_cand_transport transport) unsigned *p_cand_id)
{ {
+ /** + /**
+ * RFC 2466: an ip address can have the status DEPRECATED and SHOULD NOT + * RFC 2466: an ip address can have the status DEPRECATED and SHOULD NOT
...@@ -202,6 +202,3 @@ index 960c55156..a50c21c94 100644 ...@@ -202,6 +202,3 @@ index 960c55156..a50c21c94 100644
pj_ice_sess_cand *lcand; pj_ice_sess_cand *lcand;
pj_status_t status = PJ_SUCCESS; pj_status_t status = PJ_SUCCESS;
char address[PJ_INET6_ADDRSTRLEN]; char address[PJ_INET6_ADDRSTRLEN];
--
2.24.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment