Skip to content

Commit f5e17ef

Browse files
authored
Merge pull request #1860 from alexrabi/master
Prevent crash if path callbacks are not disabled
2 parents 959e26b + 215f86a commit f5e17ef

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

picoquic/frames.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4753,7 +4753,7 @@ const uint8_t* picoquic_decode_path_response_frame(picoquic_cnx_t* cnx, const ui
47534753
/* Provide a qualified time estimate from challenge time */
47544754
picoquic_update_path_rtt(cnx, path_x, path_x, -1, path_x->challenge_time_first, current_time, 0, 0);
47554755

4756-
if (cnx->are_path_callbacks_enabled &&
4756+
if (cnx->are_path_callbacks_enabled && cnx->callback_fn != NULL &&
47574757
cnx->callback_fn(cnx, path_x->unique_path_id, NULL, 0, picoquic_callback_path_available,
47584758
cnx->callback_ctx, path_x->app_path_ctx) != 0) {
47594759
picoquic_connection_error_ex(cnx, PICOQUIC_TRANSPORT_INTERNAL_ERROR,
@@ -5164,7 +5164,7 @@ uint8_t* picoquic_format_ready_datagram_frame(picoquic_cnx_t* cnx, picoquic_path
51645164
datagram_data_context.is_old_api = 0;
51655165
datagram_data_context.was_called = 0;
51665166

5167-
if ((cnx->callback_fn)(cnx, (cnx->are_path_callbacks_enabled)?path_x->unique_path_id:0, (uint8_t*)&datagram_data_context, allowed_space,
5167+
if (cnx->callback_fn != NULL && (cnx->callback_fn)(cnx, (cnx->are_path_callbacks_enabled)?path_x->unique_path_id:0, (uint8_t*)&datagram_data_context, allowed_space,
51685168
picoquic_callback_prepare_datagram, cnx->callback_ctx, NULL) != 0) {
51695169
/* something went wrong */
51705170
picoquic_log_app_message(cnx, "Prepare datagram returns error 0x%x", PICOQUIC_TRANSPORT_INTERNAL_ERROR);

picoquic/quicctx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,7 @@ void picoquic_delete_path(picoquic_cnx_t* cnx, int path_index)
17031703
}
17041704

17051705
/* Signal to the application */
1706-
if (cnx->are_path_callbacks_enabled &&
1706+
if (cnx->are_path_callbacks_enabled && cnx->callback_fn != NULL &&
17071707
cnx->callback_fn(cnx, path_x->unique_path_id, NULL, 0, picoquic_callback_path_deleted,
17081708
cnx->callback_ctx, path_x->app_path_ctx) != 0) {
17091709
picoquic_connection_error_ex(cnx, PICOQUIC_TRANSPORT_INTERNAL_ERROR, 0, "Path deleted callback failed.");
@@ -1958,7 +1958,7 @@ void picoquic_set_path_challenge(picoquic_cnx_t* cnx, int path_id, uint64_t curr
19581958
cnx->path[path_id]->challenge[ichal] = picoquic_public_random_64();
19591959
}
19601960
}
1961-
if (cnx->path[path_id]->challenge_verified && cnx->are_path_callbacks_enabled) {
1961+
if (cnx->path[path_id]->challenge_verified && cnx->are_path_callbacks_enabled && cnx->callback_fn != NULL) {
19621962
if (cnx->callback_fn(cnx, cnx->path[path_id]->unique_path_id, NULL, 0, picoquic_callback_path_suspended,
19631963
cnx->callback_ctx, cnx->path[path_id]->app_path_ctx) != 0) {
19641964
picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_INTERNAL_ERROR, picoquic_frame_type_path_challenge);

0 commit comments

Comments
 (0)