@@ -44,24 +44,35 @@ pub struct Dtvcc<'a> {
44
44
impl < ' a > Dtvcc < ' a > {
45
45
/// Create a new dtvcc context
46
46
pub fn new ( ctx : & ' a mut dtvcc_ctx ) -> Self {
47
- let report = unsafe { & mut * ctx. report } ;
48
- let encoder = unsafe { & mut * ( ctx. encoder as * mut encoder_ctx ) } ;
49
- let timing = unsafe { & mut * ctx. timing } ;
50
-
47
+ let report = if !ctx. report . is_null ( ) {
48
+ unsafe { Box :: new ( * ( ctx. report ) ) }
49
+ } else {
50
+ Box :: new ( ccx_decoder_dtvcc_report:: default ( ) )
51
+ } ;
52
+ let encoder = if !ctx. encoder . is_null ( ) {
53
+ unsafe { Box :: new ( * ( ctx. encoder as * mut encoder_ctx ) ) }
54
+ } else {
55
+ Box :: new ( encoder_ctx:: default ( ) )
56
+ } ;
57
+ let timing = if !ctx. timing . is_null ( ) {
58
+ unsafe { Box :: new ( * ( ctx. timing ) ) }
59
+ } else {
60
+ Box :: new ( ccx_common_timing_ctx:: default ( ) )
61
+ } ;
51
62
Self {
52
63
is_active : is_true ( ctx. is_active ) ,
53
64
active_services_count : ctx. active_services_count as u8 ,
54
65
services_active : ctx. services_active . to_vec ( ) ,
55
66
report_enabled : is_true ( ctx. report_enabled ) ,
56
- report,
67
+ report : Box :: leak ( report ) ,
57
68
decoders : ctx. decoders . iter_mut ( ) . collect ( ) ,
58
69
packet : ctx. current_packet . to_vec ( ) ,
59
70
packet_length : ctx. current_packet_length as u8 ,
60
71
is_header_parsed : is_true ( ctx. is_current_packet_header_parsed ) ,
61
72
last_sequence : ctx. last_sequence ,
62
- encoder,
73
+ encoder : Box :: leak ( encoder ) ,
63
74
no_rollup : is_true ( ctx. no_rollup ) ,
64
- timing,
75
+ timing : Box :: leak ( timing ) ,
65
76
}
66
77
}
67
78
/// Process cc data and add it to the dtvcc packet
0 commit comments