Skip to content

Commit ad57709

Browse files
MDEV-16904 inline void swap(base_list &rhs) should swap list only when list is...
not empty We should swap the list only when list is not empty.
1 parent ebaacf0 commit ad57709

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sql/sql_list.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,13 @@ class base_list :public Sql_alloc
306306
*/
307307
inline void swap(base_list &rhs)
308308
{
309+
list_node **rhs_last=rhs.last;
309310
swap_variables(list_node *, first, rhs.first);
310-
swap_variables(list_node **, last, rhs.last);
311311
swap_variables(uint, elements, rhs.elements);
312+
rhs.last= last == &first ? &rhs.first : last;
313+
last = rhs_last == &rhs.first ? &first : rhs_last;
312314
}
315+
313316
inline list_node* last_node() { return *last; }
314317
inline list_node* first_node() { return first;}
315318
inline void *head() { return first->info; }

0 commit comments

Comments
 (0)