diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-04-20 16:16:13 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-10-01 20:34:46 +0100 |
commit | 681707ec28d56494fa61a80c62500724d55f8586 (patch) | |
tree | ac6dcf1d3e62b31878d9dc4260b65629d7435561 /gcc | |
parent | 741c7350c08b0884689466867b6c9e711c7b109e (diff) | |
download | gcc-681707ec28d56494fa61a80c62500724d55f8586.zip gcc-681707ec28d56494fa61a80c62500724d55f8586.tar.gz gcc-681707ec28d56494fa61a80c62500724d55f8586.tar.bz2 |
libstdc++: Do not allocate a zero-size vector<bool> [PR 100153]
The vector<bool>::shrink_to_fit() implementation will allocate new
storage even if the vector is empty. That then leads to the
end-of-storage pointer being non-null and equal to the _M_start._M_p
pointer, which means that _M_end_addr() has undefined behaviour.
The fix is to stop doing a useless zero-sized allocation in
shrink_to_fit(), so that _M_start._M_p and _M_end_of_storage are both
null after an empty vector shrinks.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/100153
* include/bits/vector.tcc (vector<bool>::_M_shrink_to_fit()):
When size() is zero just deallocate and reset.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions