Skip to content

Commit 1e29d9f

Browse files
authored
chore: Resize vector in StringMap::RandomPairs (#5781)
On GCC 15 accessing vector element which is reserved and not resized can trigger assert. Switch to now do vector resize. Signed-off-by: mkaruza <[email protected]>
1 parent 007505e commit 1e29d9f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/string_map.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ void StringMap::RandomPairs(unsigned int count, std::vector<sds>& keys, std::vec
166166
for (unsigned int i = 0; i < index; ++i)
167167
++itr;
168168

169-
keys.reserve(count);
169+
keys.resize(count);
170170
if (with_value)
171-
vals.reserve(count);
171+
vals.resize(count);
172172

173173
while (itr != end() && pick_index < count) {
174174
auto [key, val] = *itr;

0 commit comments

Comments
 (0)