]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
core: Fix multiple trivial issues in the core.
authorCorey Farrell <git@cfware.com>
Tue, 19 Dec 2017 05:17:08 +0000 (00:17 -0500)
committerCorey Farrell <git@cfware.com>
Tue, 19 Dec 2017 14:19:46 +0000 (09:19 -0500)
* Fix small leaks in from error condition in translate.c.
* Check new file descriptor is less than 0, not less than or equal.

Change-Id: Id7782775486175c739e0c4bf3ea5e17e3f452a99

main/translate.c
main/utils.c

index 4ffe27c336c731c7bd8b3ee5fe704b4c355dd2bb..0721f07b07920684cd34d0ac3f7186d05eac7afd 100644 (file)
@@ -499,6 +499,7 @@ struct ast_trans_pvt *ast_translator_build_path(struct ast_format *dst, struct a
                        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))) {
@@ -507,9 +508,7 @@ struct ast_trans_pvt *ast_translator_build_path(struct ast_format *dst, struct a
                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;
                }
index 0b8dc7aeb02f8cd2261a728e66a8c66317516b79..b4ecffd7e19d76e52f6f3885faac54d239b03f18 100644 (file)
@@ -2664,7 +2664,7 @@ void ast_set_default_eid(struct ast_eid *eid)
        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;