diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c index b5d50e6b96..d6cd359946 100644 --- a/res/res_http_websocket.c +++ b/res/res_http_websocket.c @@ -1473,11 +1473,10 @@ int AST_OPTIONAL_API_NAME(ast_websocket_read_string) } } - if (!(*buf = ast_malloc(payload_len + 1))) { + if (!(*buf = ast_strndup(payload, payload_len))) { return -1; } - ast_copy_string(*buf, payload, payload_len + 1); return payload_len + 1; }