Skip to content

QVarLengthArray: fix aliasing error in insert(it, n, v)

Albert Astals Cid requested to merge aacid/qtbase:qvarlengtharray into kde/5.15

Taking the copy after the resize is completely pointless: the copy is there to ensure that t, being a reference potentially aliasing an element in [begin(), end()[ before the resize(), isn't invalidated by the resize(), so it must be taken before resize().

Add a comment so the next rewrite doesn't cause this to be mixed up again.

[ChangeLog][QtCore][QVarLengthArray] Fixed an aliasing bug affecting insertions of objects aliasing existing elements.

Pick-to: 6.2 6.1 6.0 5.15 5.12

Change-Id: I26bc449fa99bf8d09a19147a12a69ac4314cc61d

Reviewed-by: Giuseppe D'Angelo

(cherry picked from commit 6e57e41f)

Edited by Albert Astals Cid

Merge request reports