<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7654">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
Sean Bright: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">main/app: Fix leaks.<br><br>* ast_linear_stream would leak a file descriptor if it failed to allocate<br> lin.<br>* ast_control_tone leaked zone and ts if ast_playtones_start failed.<br><br>Additionally added whitespace to ast_linear_stream, pulled assignments<br>out of conditionals for improved readability.<br><br>Change-Id: I6d1a10cf9161b1529d939b9b2d63ea36d395b657<br>---<br>M main/app.c<br>1 file changed, 22 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/app.c b/main/app.c<br>index f35c4b7..bdf243c 100644<br>--- a/main/app.c<br>+++ b/main/app.c<br>@@ -1027,30 +1027,42 @@<br> {<br> struct linear_state *lin;<br> char tmpf[256];<br>- int res = -1;<br> int autoclose = 0;<br>+<br> if (fd < 0) {<br> if (ast_strlen_zero(filename)) {<br> return -1;<br> }<br>+<br> autoclose = 1;<br>+<br> if (filename[0] == '/') {<br> ast_copy_string(tmpf, filename, sizeof(tmpf));<br> } else {<br> snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", ast_config_AST_DATA_DIR, "sounds", filename);<br> }<br>- if ((fd = open(tmpf, O_RDONLY)) < 0) {<br>+<br>+ fd = open(tmpf, O_RDONLY);<br>+ if (fd < 0) {<br> ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", tmpf, strerror(errno));<br> return -1;<br> }<br> }<br>- if ((lin = ast_calloc(1, sizeof(*lin)))) {<br>- lin->fd = fd;<br>- lin->allowoverride = allowoverride;<br>- lin->autoclose = autoclose;<br>- res = ast_activate_generator(chan, &linearstream, lin);<br>+<br>+ lin = ast_calloc(1, sizeof(*lin));<br>+ if (!lin) {<br>+ if (autoclose) {<br>+ close(fd);<br>+ }<br>+<br>+ return -1;<br> }<br>- return res;<br>+<br>+ lin->fd = fd;<br>+ lin->allowoverride = allowoverride;<br>+ lin->autoclose = autoclose;<br>+<br>+ return ast_activate_generator(chan, &linearstream, lin);<br> }<br> <br> static int control_streamfile(struct ast_channel *chan,<br>@@ -1349,10 +1361,10 @@<br> ts = ast_get_indication_tone(zone ? zone : ast_channel_zone(chan), tone_indication);<br> <br> if (ast_playtones_start(chan, 0, ts ? ts->data : tone_indication, 0)) {<br>- return -1;<br>+ res = -1;<br> }<br> <br>- for (;;) {<br>+ while (!res) {<br> struct ast_frame *fr;<br> <br> if (ast_waitfor(chan, -1) < 0) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7654">change 7654</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7654"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I6d1a10cf9161b1529d939b9b2d63ea36d395b657 </div>
<div style="display:none"> Gerrit-Change-Number: 7654 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>