Fix a variety of memory leaks
[asterisk/asterisk.git] / res / res_rtp_asterisk.c
index 62a3211..32b762e 100644 (file)
@@ -566,6 +566,8 @@ static int ast_rtp_new(struct ast_rtp_instance *instance,
                /* See if we ran out of ports or if the bind actually failed because of something other than the address being in use */
                if (x == startplace || errno != EADDRINUSE) {
                        ast_log(LOG_ERROR, "Oh dear... we couldn't allocate a port for RTP instance '%p'\n", instance);
+                       close(rtp->s);
+                       ast_free(rtp);
                        return -1;
                }
        }