]> granicus.if.org Git - graphviz/commitdiff
mark Block as an uncopyable object
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 12 Jun 2021 20:14:01 +0000 (13:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Jun 2021 19:24:07 +0000 (12:24 -0700)
Objects of type Block were already unsafe to copy (or move). The class contains
raw pointers that are deleted in the destructor. So any attempt to copy an
object of this type would have eventually caused a use-after-free and/or a
double free. This change makes the situation more explicit by teaching the
compiler it is unsafe to copy or move objects of this type. If there is code that
implicitly does this, it will now be rejected at compile time.

lib/vpsc/block.h

index be6329f128ebc86163a993a5aae3fdfb405c4a27..9055c14e579bf91c689c1b8c730a89cae0a840fd 100644 (file)
@@ -34,6 +34,7 @@ public:
        double weight;
        double wposn;
        Block(Variable *v=nullptr);
+       Block(const Block &) = delete;
        ~Block();
        Constraint* findMinLM();
        Constraint* findMinLMBetween(Variable* lv, Variable* rv);