File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ class CanMsg : public Printable
4545 , data_length{min (can_data_len, MAX_DATA_LENGTH)}
4646 , data{0 }
4747 {
48- memcpy (data, can_data_ptr, data_length);
48+ if (data_length && can_data_ptr)
49+ memcpy (data, can_data_ptr, data_length);
4950 }
5051
5152 CanMsg () : CanMsg(0 , 0 , nullptr ) { }
@@ -54,7 +55,8 @@ class CanMsg : public Printable
5455 {
5556 this ->id = other.id ;
5657 this ->data_length = other.data_length ;
57- memcpy (this ->data , other.data , this ->data_length );
58+ if (this ->data_length && other.data )
59+ memcpy (this ->data , other.data , this ->data_length );
5860 }
5961
6062 virtual ~CanMsg () { }
@@ -65,7 +67,8 @@ class CanMsg : public Printable
6567 {
6668 this ->id = other.id ;
6769 this ->data_length = other.data_length ;
68- memcpy (this ->data , other.data , this ->data_length );
70+ if (this ->data_length && other.data )
71+ memcpy (this ->data , other.data , this ->data_length );
6972 }
7073 return (*this );
7174 }
You can’t perform that action at this time.
0 commit comments