@@ -69,6 +69,21 @@ struct test_xhdr
6969
7070static struct network_path network_path ;
7171static struct http1x_ctor_ctx hsi_ctx = { .is_server = 1 , };
72+ static unsigned n_header_sets_discarded ;
73+
74+
75+ static void
76+ discard_header_set (void * hset )
77+ {
78+ ++ n_header_sets_discarded ;
79+ lsquic_http1x_if -> hsi_discard_header_set (hset );
80+ }
81+
82+
83+ static const struct lsquic_hset_if discard_count_hset_if =
84+ {
85+ .hsi_discard_header_set = discard_header_set ,
86+ };
7287
7388
7489static int
@@ -143,7 +158,8 @@ lsquic_engine_add_conn_to_tickable (struct lsquic_engine_public *enpub,
143158
144159
145160static void
146- init_test_objs (struct test_objs * tobjs )
161+ init_test_objs_with_qpack_capacity (struct test_objs * tobjs ,
162+ unsigned qpack_capacity )
147163{
148164 int s ;
149165
@@ -179,11 +195,19 @@ init_test_objs (struct test_objs *tobjs)
179195 lsquic_qeh_init (& tobjs -> qeh , & tobjs -> lconn );
180196 s = lsquic_qeh_settings (& tobjs -> qeh , 0 , 0 , 0 , 0 );
181197 assert (0 == s );
182- lsquic_qdh_init (& tobjs -> qdh , & tobjs -> lconn , 1 , tobjs -> conn_pub .enpub , 0 , 0 );
198+ lsquic_qdh_init (& tobjs -> qdh , & tobjs -> lconn , 1 , tobjs -> conn_pub .enpub ,
199+ qpack_capacity , 0 );
183200 tobjs -> conn_pub .u .ietf .qdh = & tobjs -> qdh ;
184201}
185202
186203
204+ static void
205+ init_test_objs (struct test_objs * tobjs )
206+ {
207+ init_test_objs_with_qpack_capacity (tobjs , 0 );
208+ }
209+
210+
187211static void
188212deinit_test_objs (struct test_objs * tobjs )
189213{
@@ -424,6 +448,51 @@ test_priority_update_during_partial_header_decode_wins (void)
424448}
425449
426450
451+ static void
452+ test_destroy_unfinished_stream_without_qpack_decoder_stream (void )
453+ {
454+ struct test_objs tobjs ;
455+ struct lsquic_stream * stream ;
456+
457+ init_test_objs_with_qpack_capacity (& tobjs , 0x100 );
458+ assert (NULL == tobjs .qdh .qdh_dec_sm_out );
459+
460+ stream = new_http_prio_stream (& tobjs );
461+ lsquic_stream_destroy (stream );
462+
463+ deinit_test_objs (& tobjs );
464+ }
465+
466+
467+ static void
468+ test_destroy_partial_header_without_qpack_decoder_stream (void )
469+ {
470+ struct test_objs tobjs ;
471+ struct lsquic_stream * stream ;
472+ const unsigned char header_block [] = { 0 , 0 , };
473+ const unsigned char * buf ;
474+ enum lsqpack_read_header_status rhs ;
475+
476+ init_test_objs_with_qpack_capacity (& tobjs , 0x100 );
477+ assert (NULL == tobjs .qdh .qdh_dec_sm_out );
478+ stream = new_http_prio_stream (& tobjs );
479+
480+ buf = header_block ;
481+ rhs = lsquic_qdh_header_in_begin (& tobjs .qdh , stream ,
482+ sizeof (header_block ), & buf , 1 );
483+ assert (LQRHS_NEED == rhs );
484+ assert (stream -> sm_hblock_ctx );
485+ stream -> sm_qflags |= SMQF_QPACK_DEC ;
486+
487+ n_header_sets_discarded = 0 ;
488+ tobjs .eng_pub .enp_hsi_if = & discard_count_hset_if ;
489+ lsquic_stream_destroy (stream );
490+ assert (1 == n_header_sets_discarded );
491+
492+ deinit_test_objs (& tobjs );
493+ }
494+
495+
427496int
428497main (void )
429498{
@@ -432,6 +501,8 @@ main (void)
432501 test_split_priority_header_fields_are_one_dictionary ();
433502 test_user_set_http_prio_does_not_block_priority_header ();
434503 test_priority_update_during_partial_header_decode_wins ();
504+ test_destroy_unfinished_stream_without_qpack_decoder_stream ();
505+ test_destroy_partial_header_without_qpack_decoder_stream ();
435506
436507 lsquic_global_cleanup ();
437508 return 0 ;
0 commit comments