Commit d44e752f authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Don't allow queueing websocket receive if another is pending.

parent 04fcadac
...@@ -3743,13 +3743,24 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D ...@@ -3743,13 +3743,24 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
{ {
struct socket_receive *r; struct socket_receive *r;
if (!(r = malloc( sizeof(*r) ))) return FALSE; if (InterlockedIncrement( &socket->hdr.pending_receives ) > 1)
{
InterlockedDecrement( &socket->hdr.pending_receives );
WARN( "Attempt to queue receive while another is pending.\n" );
release_object( &socket->hdr );
return ERROR_INVALID_OPERATION;
}
if (!(r = malloc( sizeof(*r) )))
{
InterlockedDecrement( &socket->hdr.pending_receives );
return ERROR_OUTOFMEMORY;
}
r->socket = socket; r->socket = socket;
r->buf = buf; r->buf = buf;
r->len = len; r->len = len;
addref_object( &socket->hdr ); addref_object( &socket->hdr );
InterlockedIncrement( &socket->hdr.pending_receives );
if ((ret = queue_task( &socket->recv_q, task_socket_receive, r ))) if ((ret = queue_task( &socket->recv_q, task_socket_receive, r )))
{ {
InterlockedDecrement( &socket->hdr.pending_receives ); InterlockedDecrement( &socket->hdr.pending_receives );
......
...@@ -1104,6 +1104,8 @@ static void test_websocket(BOOL secure) ...@@ -1104,6 +1104,8 @@ static void test_websocket(BOOL secure)
err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type ); err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type );
ok( err == ERROR_SUCCESS, "got %u\n", err ); ok( err == ERROR_SUCCESS, "got %u\n", err );
err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type );
ok( err == ERROR_INVALID_OPERATION, "got %u\n", err );
setup_test( &info, winhttp_websocket_shutdown, __LINE__ ); setup_test( &info, winhttp_websocket_shutdown, __LINE__ );
ws_status = (WINHTTP_WEB_SOCKET_STATUS *)info.buffer; ws_status = (WINHTTP_WEB_SOCKET_STATUS *)info.buffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment