~BPFModule was segfaulting because tables_ was an empty pointer. The
pointer is valid only for valid compilations. Add a test as well.
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
engine_.reset();
rw_engine_.reset();
ctx_.reset();
- for (auto table : *tables_) {
- if (table.is_shared)
- SharedTables::instance()->remove_fd(table.name);
+ if (tables_) {
+ for (auto table : *tables_) {
+ if (table.is_shared)
+ SharedTables::instance()->remove_fd(table.name);
+ }
}
}
b1 = BPF(text="""BPF_TABLE_PUBLIC("hash", int, int, table1, 10);""")
b2 = BPF(text="""BPF_TABLE("extern", int, int, table1, 10);""")
+ def test_syntax_error(self):
+ with self.assertRaises(Exception):
+ b = BPF(text="""int failure(void *ctx) { if (); return 0; }""")
+
if __name__ == "__main__":
main()