[Asterisk-code-review] res_http_websocket: Add trailing zero for text strings (asterisk[master])

Sean Bright asteriskteam at digium.com
Thu Jul 9 12:06:44 CDT 2020


Sean Bright has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/14626 )

Change subject: res_http_websocket: Add trailing zero for text strings
......................................................................


Patch Set 1: Code-Review-1

(1 comment)

I don't disagree with Richard's comments, but this approach avoids ast_copy_string() and the "manual" string creation.

https://gerrit.asterisk.org/c/asterisk/+/14626/1/res/res_http_websocket.c 
File res/res_http_websocket.c:

https://gerrit.asterisk.org/c/asterisk/+/14626/1/res/res_http_websocket.c@1469 
PS1, Line 1469: 
              : 	if (!(*buf = ast_malloc(payload_len + 1))) {
              : 		return -1;
              : 	}
              : 
              : 	memcpy(*buf, payload, payload_len);
              : 	(*buf)[payload_len] = 0;
We can replace this whole block with:

 if (!(*buf = ast_strndup(payload, payload_len))) {
     return -1;
 }
 return payload_len + 1;



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14626
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib4a75cffeb1eb8cf01136ef30306bd623e531a2a
Gerrit-Change-Number: 14626
Gerrit-PatchSet: 1
Gerrit-Owner: Nickolay V. Shmyrev <nshmyrev at alphacephei.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-Comment-Date: Thu, 09 Jul 2020 17:06:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200709/324218e1/attachment.html>


More information about the asterisk-code-review mailing list