File tree 1 file changed +6
-3
lines changed
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
45
45
, data_length{min (can_data_len, MAX_DATA_LENGTH)}
46
46
, data{0 }
47
47
{
48
- memcpy (data, can_data_ptr, data_length);
48
+ if (data_length && can_data_ptr)
49
+ memcpy (data, can_data_ptr, data_length);
49
50
}
50
51
51
52
CanMsg () : CanMsg(0 , 0 , nullptr ) { }
@@ -54,7 +55,8 @@ class CanMsg : public Printable
54
55
{
55
56
this ->id = other.id ;
56
57
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 );
58
60
}
59
61
60
62
virtual ~CanMsg () { }
@@ -65,7 +67,8 @@ class CanMsg : public Printable
65
67
{
66
68
this ->id = other.id ;
67
69
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 );
69
72
}
70
73
return (*this );
71
74
}
You can’t perform that action at this time.
0 commit comments