Skip to content

Commit

Permalink
avoid parsing whitespace as invalid JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
htrendev committed Apr 27, 2023
1 parent bd536b4 commit e81b3de
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions transports/janus_websockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,9 @@ static int janus_websockets_common_callback(
incoming_curr += error.position;
JANUS_LOG(LOG_HUGE, "[%s-%p] Parsed JSON message - consumed %zu/%zu bytes\n",
log_prefix, wsi, (size_t)(incoming_curr - ws_client->incoming), incoming_length);
/* Trailing whitespace after the last message results in invalid JSON error */
while isspace(*incoming_curr)
incoming_curr++;
if(incoming_curr == incoming_end) {
/* Process messages in order */
json_t **msg = message_buffer;
Expand Down

0 comments on commit e81b3de

Please sign in to comment.