Commit cef601b
committed
Fix capnproto add_value_to_map overwriting all entries at index 0
add_value_to_map constructed a fresh OutputArrayType each call without
using _parent->ix_++, so ix_ always defaulted to 0 and every map entry
overwrote slot 0 in the Cap'n Proto entries list. Only the last entry
survived serialization; on read-back the remaining default entries (with
empty-string keys) triggered stoull errors.
Fix by using designated initializers with .ix_ = _parent->ix_++,
matching all other add_*_to_map methods in Writer.cpp. Also wrap the
key _name in std::string() so add_value_to_object deduces T as
std::string rather than std::string_view, which has no handling branch.
Add test_map_value_types to exercise maps with primitive value types
(std::map<std::string, std::string>) through add_value_to_map.
Made-with: Cursor1 parent 9d9f840 commit cef601b
2 files changed
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
190 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
191 | 192 | | |
192 | | - | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments