forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
c++: use after free during name lookup w/ modules [PR99479]
name_lookup::search_unqualified uses a statically allocated vector in order to avoid repeated reallocation, under the assumption that the function can't be called recursively. With modules however, this assumption turns out to be false, and search_unqualified can be called recursively as demonstrated by the testcase in comment gcc-mirror#19 of PR99479[1] where the recursive call causes the vector to get reallocated which invalidates the reference to queue[ix] held by the parent call. This patch makes search_unqualified instead use an auto_vec with 16 elements of internal storage. In turn we can simplify the API of some member functions to take the vector by reference and return void. [1]: https://gcc.gnu.org/PR99479#c19 PR c++/99479 gcc/cp/ChangeLog: * name-lookup.cc (name_lookup::using_queue): Change to an auto_vec (with 16 elements of internal storage). (name_lookup::queue_namespace): Change return type to void, take queue parameter by reference and adjust function body accordingly. (name_lookup::do_queue_usings): Inline into ... (name_lookup::queue_usings): ... here. As in queue_namespace. (name_lookup::search_unqualified): Don't make queue static, remove length variable, and adjust function body accordingly.
- Loading branch information
Patrick Palka
committed
Apr 7, 2022
1 parent
68163cc
commit 7e7a96f
Showing
1 changed file
with
22 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters