[sr-dev] git:master:145d10f5: websocket: use sizeof over the type of the pointer to be allocated

Daniel-Constantin Mierla miconda at gmail.com
Fri Jun 30 14:16:58 CEST 2017


Module: kamailio
Branch: master
Commit: 145d10f5a2dcad3cbdb477aaabdc853bb606b355
URL: https://github.com/kamailio/kamailio/commit/145d10f5a2dcad3cbdb477aaabdc853bb606b355

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-06-30T13:36:26+02:00

websocket: use sizeof over the type of the pointer to be allocated

---

Modified: src/modules/websocket/ws_frame.c

---

Diff:  https://github.com/kamailio/kamailio/commit/145d10f5a2dcad3cbdb477aaabdc853bb606b355.diff
Patch: https://github.com/kamailio/kamailio/commit/145d10f5a2dcad3cbdb477aaabdc853bb606b355.patch

---

diff --git a/src/modules/websocket/ws_frame.c b/src/modules/websocket/ws_frame.c
index a01953959a..6af2bb039e 100644
--- a/src/modules/websocket/ws_frame.c
+++ b/src/modules/websocket/ws_frame.c
@@ -209,13 +209,13 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t conn_close)
 
 	/* Allocate send buffer and build frame */
 	frame_length = frame->payload_len + extended_length + 2;
-	if ((send_buf = pkg_malloc(sizeof(unsigned char) * frame_length))
+	if ((send_buf = pkg_malloc(sizeof(char) * frame_length))
 			== NULL)
 	{
 		LM_ERR("allocating send buffer from pkg memory\n");
 		return -1;
 	}
-	memset(send_buf, 0, sizeof(unsigned char) * frame_length);
+	memset(send_buf, 0, sizeof(char) * frame_length);
 	send_buf[pos++] = 0x80 | (frame->opcode & 0xff);
 	if (extended_length == 0)
 		send_buf[pos++] = (frame->payload_len & 0xff);




More information about the sr-dev mailing list