Skip to content

Commit babbf8c

Browse files
committed
fts_query_free(): Fix a potential assertion failure
The ownership of the field query->intersection usually transfers to query->doc_ids. In some error scenario, it could be possible that fts_query_free() would be invoked with query->intersection!=NULL. Let us handle that case, instead of intentionally crashing the server.
1 parent 30e89ac commit babbf8c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

storage/innobase/fts/fts0que.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -3633,6 +3634,10 @@ fts_query_free(
36333634
fts_doc_ids_free(query->deleted);
36343635
}
36353636

3637+
if (query->intersection) {
3638+
fts_query_free_doc_ids(query, query->intersection);
3639+
}
3640+
36363641
if (query->doc_ids) {
36373642
fts_query_free_doc_ids(query, query->doc_ids);
36383643
}
@@ -3657,8 +3662,6 @@ fts_query_free(
36573662
rbt_free(query->word_freqs);
36583663
}
36593664

3660-
ut_a(!query->intersection);
3661-
36623665
if (query->word_map) {
36633666
rbt_free(query->word_map);
36643667
}

storage/xtradb/fts/fts0que.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -3653,6 +3654,10 @@ fts_query_free(
36533654
fts_doc_ids_free(query->deleted);
36543655
}
36553656

3657+
if (query->intersection) {
3658+
fts_query_free_doc_ids(query, query->intersection);
3659+
}
3660+
36563661
if (query->doc_ids) {
36573662
fts_query_free_doc_ids(query, query->doc_ids);
36583663
}
@@ -3677,8 +3682,6 @@ fts_query_free(
36773682
rbt_free(query->word_freqs);
36783683
}
36793684

3680-
ut_a(!query->intersection);
3681-
36823685
if (query->word_map) {
36833686
rbt_free(query->word_map);
36843687
}

0 commit comments

Comments
 (0)