mirror of
https://github.com/curl/curl.git
synced 2026-04-15 00:51:42 +03:00
websocket: Avoid memory leak in error path
In the errorpath for randstr being too long to copy into the buffer we leak the randstr when returning CURLE_FAILED_INIT. Fix by using an explicit free on randstr in the errorpath. Closes: #13602 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
This commit is contained in:
parent
4d96873a4d
commit
266baf2d34
1 changed files with 3 additions and 1 deletions
4
lib/ws.c
4
lib/ws.c
|
|
@ -718,8 +718,10 @@ CURLcode Curl_ws_request(struct Curl_easy *data, REQTYPE *req)
|
|||
if(result)
|
||||
return result;
|
||||
DEBUGASSERT(randlen < sizeof(keyval));
|
||||
if(randlen >= sizeof(keyval))
|
||||
if(randlen >= sizeof(keyval)) {
|
||||
free(randstr);
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
strcpy(keyval, randstr);
|
||||
free(randstr);
|
||||
for(i = 0; !result && (i < sizeof(heads)/sizeof(heads[0])); i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue