Skip to content

Commit

Permalink
fts_query_free(): Fix a potential assertion failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Oct 18, 2017
1 parent 30e89ac commit babbf8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions storage/innobase/fts/fts0que.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -3633,6 +3634,10 @@ fts_query_free(
fts_doc_ids_free(query->deleted);
}

if (query->intersection) {
fts_query_free_doc_ids(query, query->intersection);
}

if (query->doc_ids) {
fts_query_free_doc_ids(query, query->doc_ids);
}
Expand All @@ -3657,8 +3662,6 @@ fts_query_free(
rbt_free(query->word_freqs);
}

ut_a(!query->intersection);

if (query->word_map) {
rbt_free(query->word_map);
}
Expand Down
7 changes: 5 additions & 2 deletions storage/xtradb/fts/fts0que.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -3653,6 +3654,10 @@ fts_query_free(
fts_doc_ids_free(query->deleted);
}

if (query->intersection) {
fts_query_free_doc_ids(query, query->intersection);
}

if (query->doc_ids) {
fts_query_free_doc_ids(query, query->doc_ids);
}
Expand All @@ -3677,8 +3682,6 @@ fts_query_free(
rbt_free(query->word_freqs);
}

ut_a(!query->intersection);

if (query->word_map) {
rbt_free(query->word_map);
}
Expand Down

0 comments on commit babbf8c

Please sign in to comment.