<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8253">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_http_websocket: Don't leak memory on read failure<br><br>Change-Id: Ic449ea832bc81a1671c0e910c5fbe8c683e3da89<br>---<br>M res/res_http_websocket.c<br>1 file changed, 4 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/53/8253/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c<br>index 956c52c..e39baf1 100644<br>--- a/res/res_http_websocket.c<br>+++ b/res/res_http_websocket.c<br>@@ -662,14 +662,14 @@<br> }<br> } else if (*opcode == AST_WEBSOCKET_OPCODE_CLOSE) {<br> /* Make the payload available so the user can look at the reason code if they so desire */<br>- if ((*payload_len) && (new_payload = ast_realloc(session->payload, *payload_len))) {<br>- if (ws_safe_read(session, &buf[frame_size], (*payload_len), opcode)) {<br>+ if (*payload_len && (new_payload = ast_realloc(session->payload, *payload_len))) {<br>+ session->payload = new_payload;<br>+ if (ws_safe_read(session, &buf[frame_size], *payload_len, opcode)) {<br> return -1;<br> }<br>- session->payload = new_payload;<br> memcpy(session->payload, &buf[frame_size], *payload_len);<br> *payload = session->payload;<br>- frame_size += (*payload_len);<br>+ frame_size += *payload_len;<br> }<br> <br> session->closing = 1;<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8253">change 8253</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/8253"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ic449ea832bc81a1671c0e910c5fbe8c683e3da89 </div>
<div style="display:none"> Gerrit-Change-Number: 8253 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>