[Asterisk-code-review] res http websocket: Don't leak memory on read failure (asterisk[13])
Sean Bright
asteriskteam at digium.com
Sun Feb 18 12:02:52 CST 2018
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/8253
Change subject: res_http_websocket: Don't leak memory on read failure
......................................................................
res_http_websocket: Don't leak memory on read failure
Change-Id: Ic449ea832bc81a1671c0e910c5fbe8c683e3da89
---
M res/res_http_websocket.c
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/53/8253/1
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 956c52c..e39baf1 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -662,14 +662,14 @@
}
} else if (*opcode == AST_WEBSOCKET_OPCODE_CLOSE) {
/* Make the payload available so the user can look at the reason code if they so desire */
- if ((*payload_len) && (new_payload = ast_realloc(session->payload, *payload_len))) {
- if (ws_safe_read(session, &buf[frame_size], (*payload_len), opcode)) {
+ if (*payload_len && (new_payload = ast_realloc(session->payload, *payload_len))) {
+ session->payload = new_payload;
+ if (ws_safe_read(session, &buf[frame_size], *payload_len, opcode)) {
return -1;
}
- session->payload = new_payload;
memcpy(session->payload, &buf[frame_size], *payload_len);
*payload = session->payload;
- frame_size += (*payload_len);
+ frame_size += *payload_len;
}
session->closing = 1;
--
To view, visit https://gerrit.asterisk.org/8253
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic449ea832bc81a1671c0e910c5fbe8c683e3da89
Gerrit-Change-Number: 8253
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180218/b1e21878/attachment.html>
More information about the asterisk-code-review
mailing list