File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
rclrs/src/dynamic_message Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,9 @@ impl TypeErasedSequence {
196
196
T : Proxy < ' msg > ,
197
197
{
198
198
let element_size = T :: size_in_memory ( metadata) ;
199
+ if self . data . is_null ( ) {
200
+ return Vec :: new ( ) ;
201
+ } ;
199
202
let sequence_data =
200
203
std:: slice:: from_raw_parts ( self . data as * const u8 , self . size * element_size) ;
201
204
check :: < T > ( sequence_data) ;
@@ -210,6 +213,9 @@ impl TypeErasedSequence {
210
213
T : ProxyMut < ' msg > ,
211
214
{
212
215
let element_size = T :: size_in_memory ( metadata) ;
216
+ if self . data . is_null ( ) {
217
+ return Vec :: new ( ) ;
218
+ } ;
213
219
let sequence_data =
214
220
std:: slice:: from_raw_parts_mut ( self . data as * mut u8 , self . size * element_size) ;
215
221
check :: < T > ( sequence_data) ;
Original file line number Diff line number Diff line change @@ -1141,4 +1141,16 @@ mod tests {
1141
1141
let _dyn_msg =
1142
1142
DynamicMessage :: new ( "test_msgs/msg/BoundedSequences" . try_into ( ) . unwrap ( ) ) . unwrap ( ) ;
1143
1143
}
1144
+
1145
+ #[ test]
1146
+ fn empty_sequence_issue_492 ( ) {
1147
+ let message_type = MessageTypeName {
1148
+ package_name : "test_msgs" . to_owned ( ) ,
1149
+ type_name : "UnboundedSequences" . to_owned ( ) ,
1150
+ } ;
1151
+ let mut msg = DynamicMessage :: new ( message_type) . unwrap ( ) ;
1152
+
1153
+ let _ = msg. get ( "basic_types_values" ) ;
1154
+ let _ = msg. get_mut ( "basic_types_values" ) ;
1155
+ }
1144
1156
}
You can’t perform that action at this time.
0 commit comments