Skip to content

Commit efaf28a

Browse files
committed
Merge branch '94xhn-fix/websocket-pop-first-message-realloc-size'
2 parents 95ccf40 + 191cfde commit efaf28a

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

API.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ int websocket_extension_server_match(const char * extension_client,
15961596
int websocket_extension_client_match(const char * extension_server, void * user_data, void ** context);
15971597
```
15981598
1599-
The callback function `websocket_extension_message_out_perform` can modify the message data and data lenght and the RSV flags. The callback function `websocket_extension_message_in_perform` can modify the message data only. Inside these functions, `data_in` and `data_len_in` are the current data, your extension callback function must update `data_out` with a `o_malloc`'ed data and set the new data length using `data_len_out` and return `U_OK` on success.
1599+
The callback function `websocket_extension_message_out_perform` can modify the message data and data length and the RSV flags. The callback function `websocket_extension_message_in_perform` can modify the message data only. Inside these functions, `data_in` and `data_len_in` are the current data, your extension callback function must update `data_out` with a `o_malloc`'ed data and set the new data length using `data_len_out` and return `U_OK` on success.
16001600
If your function doesn't return `U_OK`, the message data won't be updated and `data_out` won't be free'd if set.
16011601
16021602
You can call `ulfius_add_websocket_extension_message_perform` or `ulfius_add_websocket_client_extension_message_perform` multiple times for a websocket definition. In that case the extension callbacks function will be called in the same order for the `websocket_extension_message_out_perform` callbacks, and in reverse order for the `websocket_extension_message_in_perform` callbacks.
@@ -1652,15 +1652,15 @@ int ulfius_websocket_send_close_signal(struct _websocket_manager * websocket_man
16521652
/**
16531653
* Returns the status of the websocket connection
16541654
* Returned values can be U_WEBSOCKET_STATUS_OPEN or U_WEBSOCKET_STATUS_CLOSE
1655-
* wether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
1655+
* whether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
16561656
*/
16571657
int ulfius_websocket_status(struct _websocket_manager * websocket_manager);
16581658

16591659
/**
16601660
* Wait until the websocket connection is closed or the timeout in milliseconds is reached
16611661
* if timeout is 0, no timeout is set
16621662
* Returned values can be U_WEBSOCKET_STATUS_OPEN or U_WEBSOCKET_STATUS_CLOSE
1663-
* wether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
1663+
* whether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
16641664
*/
16651665
int ulfius_websocket_wait_close(struct _websocket_manager * websocket_manager, unsigned int timeout);
16661666
```
@@ -1798,15 +1798,15 @@ int ulfius_websocket_client_connection_close(struct _websocket_client_handler *
17981798
/**
17991799
* Returns the status of the websocket client connection
18001800
* Returned values can be U_WEBSOCKET_STATUS_OPEN or U_WEBSOCKET_STATUS_CLOSE
1801-
* wether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
1801+
* whether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
18021802
*/
18031803
int ulfius_websocket_client_connection_status(struct _websocket_client_handler * websocket_client_handler);
18041804

18051805
/**
18061806
* Wait until the websocket client connection is closed or the timeout in milliseconds is reached
18071807
* if timeout is 0, no timeout is set
18081808
* Returned values can be U_WEBSOCKET_STATUS_OPEN or U_WEBSOCKET_STATUS_CLOSE
1809-
* wether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
1809+
* whether the websocket is open or closed, or U_WEBSOCKET_STATUS_ERROR on error
18101810
*/
18111811
int ulfius_websocket_client_connection_wait_close(struct _websocket_client_handler * websocket_client_handler, unsigned int timeout);
18121812
```
@@ -1849,7 +1849,7 @@ int ulfius_send_http_request(const struct _u_request * request, struct _u_respon
18491849
/**
18501850
* ulfius_send_http_request_with_limit
18511851
* Send a HTTP request and store the result into a _u_response
1852-
* The response body lenght and number of parsed headers can be limited
1852+
* The response body length and number of parsed headers can be limited
18531853
* @param request the struct _u_request that contains all the input parameters to perform the HTTP request
18541854
* @param response the struct _u_response that will be filled with all response parameter values, optional, may be NULL
18551855
* @param response_body_limit the maximum size of the response body to retrieve, 0 means no limit

src/u_websocket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ struct _websocket_message * ulfius_websocket_pop_first_message(struct _websocket
16461646
message_list->list[len] = message_list->list[len+1];
16471647
}
16481648
if (message_list->len > 1) {
1649-
message_list->list = o_realloc(message_list->list, (message_list->len-1));
1649+
message_list->list = o_realloc(message_list->list, (message_list->len-1)*sizeof(struct _websocket_message *));
16501650
} else {
16511651
o_free(message_list->list);
16521652
message_list->list = NULL;

0 commit comments

Comments
 (0)