Commit c246021
committed
demo: fix stack corruption in ping_pong demo
While running the ping_pong demo I noticed a crash:
ping_pong_1-1 | [ros2run]: Aborted
ping_pong_1-1 | [INFO] [1775242528.757714440] []: Created a timer with period 2000 ms.
ping_pong_1-1 |
ping_pong_2-1 | realloc(): invalid old size
ping_pong_1-1 | mremap_chunk(): invalid pointer
ping_pong_2-1 | [ros2run]: Aborted
ping_pong_1-1 | [ros2run]: Aborted
This is caused by stack memory being passed to realloc() at
https://github.com/ros2/rosidl/blob/8cdfe315157f8bffa9b73b6750c52f44325a7847/rosidl_runtime_c/src/string_functions.c#L110
Use ros string allocators to handle this safely. The outcoming_ping
is sprintf'd so we must preallocate.
Signed-off-by: Cory Todd <cory@219design.com>1 parent b86db30 commit c246021
1 file changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
117 | 123 | | |
| 124 | + | |
118 | 125 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
0 commit comments