[Asterisk-code-review] core: Fix multiple trivial issues in the core. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Tue Dec 19 07:52:38 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7658


Change subject: core: Fix multiple trivial issues in the core.
......................................................................

core: Fix multiple trivial issues in the core.

* Fix small leaks in from error conditions in sdp.c and translate.c.
* Check new file descriptor is less than 0, not less than or equal.

Change-Id: Id7782775486175c739e0c4bf3ea5e17e3f452a99
---
M main/sdp.c
M main/translate.c
M main/utils.c
3 files changed, 4 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/7658/1

diff --git a/main/sdp.c b/main/sdp.c
index fd10ba8..7e283eb 100644
--- a/main/sdp.c
+++ b/main/sdp.c
@@ -845,6 +845,7 @@
 			rtp_codecs_free(codecs);
 			ast_stream_free(stream);
 			ao2_ref(caps, -1);
+			ast_free(codecs);
 			return NULL;
 		}
 		ast_stream_set_data(stream, AST_STREAM_DATA_RTP_CODECS, codecs,
diff --git a/main/translate.c b/main/translate.c
index ce4745c..02717c5 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -497,6 +497,7 @@
 			ast_log(LOG_WARNING, "No translator path from %s to %s\n",
 				ast_format_get_name(src), ast_format_get_name(dst));
 			AST_RWLIST_UNLOCK(&translators);
+			ast_translator_free_path(head);
 			return NULL;
 		}
 		if ((t->dst_codec.sample_rate == ast_format_get_sample_rate(dst)) && (t->dst_codec.type == ast_format_get_type(dst))) {
@@ -505,9 +506,7 @@
 		if (!(cur = newpvt(t, explicit_dst))) {
 			ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n",
 				ast_format_get_name(src), ast_format_get_name(dst));
-			if (head) {
-				ast_translator_free_path(head);
-			}
+			ast_translator_free_path(head);
 			AST_RWLIST_UNLOCK(&translators);
 			return NULL;
 		}
diff --git a/main/utils.c b/main/utils.c
index 931a1ae..85228c1 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -2615,7 +2615,7 @@
 	unsigned char full_mac[6]  = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
 
 	s = socket(AF_INET, SOCK_STREAM, 0);
-	if (s <= 0) {
+	if (s < 0) {
 		ast_log(LOG_WARNING, "Unable to open socket for seeding global EID. "
 			"You will have to set it manually.\n");
 		return;

-- 
To view, visit https://gerrit.asterisk.org/7658
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7782775486175c739e0c4bf3ea5e17e3f452a99
Gerrit-Change-Number: 7658
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171219/2b17cfa5/attachment.html>


More information about the asterisk-code-review mailing list