Commit c2ed5b6
authored
Fix use-after-free bug of DataType value.
Everytime when we call DataType<T>::value(), a new string is constructed and assign to the static data_type. So if we call it twice, the first one has been released when we get the second one.
std::string data_type(value1, strlen(value2));
If the parameters are evaluated from left to right, value1 becomes invalid while we are using it to construct data_type.
This is the simplest fix, which passes a single c_str as parameter.
A better solution is to refactor this whole piece of code, to try to avoid constructing data_type everytime, or avoid c_str.1 parent ca1bf3a commit c2ed5b6
File tree
1 file changed
+1
-1
lines changed- ros/roscpp_core/roscpp_traits/include/ros
1 file changed
+1
-1
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
0 commit comments