mirror of
https://github.com/curl/curl.git
synced 2024-12-09 06:30:06 +08: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
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…
Reference in New Issue
Block a user