diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2019-09-13 12:01:02 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2019-09-13 12:01:02 +0300 |
commit | 177a96a768b7fb9abd37b39d47b9a3a1c9e976af (patch) | |
tree | 84788423acb76b15df1805f408d2ea70e49af6c6 /src/libnest2d | |
parent | 7fe691f14efd1d89f3190b2fc12e5d907c0082d5 (diff) |
Fix arrange crash with ASAN
Diffstat (limited to 'src/libnest2d')
-rw-r--r-- | src/libnest2d/include/libnest2d/selections/selection_boilerplate.hpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libnest2d/include/libnest2d/selections/selection_boilerplate.hpp b/src/libnest2d/include/libnest2d/selections/selection_boilerplate.hpp index 4bb2e72af..2df9a26c3 100644 --- a/src/libnest2d/include/libnest2d/selections/selection_boilerplate.hpp +++ b/src/libnest2d/include/libnest2d/selections/selection_boilerplate.hpp @@ -33,10 +33,16 @@ protected: // then it should be removed from the list auto it = c.begin(); while (it != c.end() && !stopcond_()) { - Placer p{bin}; - p.configure(pcfg); + + // WARNING: The copy of itm needs to be created before Placer. + // Placer is working with references and its destructor still + // manipulates the item this is why the order of stack creation + // matters here. const Item& itm = *it; Item cpy{itm}; + + Placer p{bin}; + p.configure(pcfg); if (!p.pack(cpy)) it = c.erase(it); else it++; } |