提交 09dc8bf3 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

0-initialize all members of the struct to avoid stupid segfaults on

errors during initialization.
上级 32cd50df
...@@ -276,7 +276,18 @@ def struct_gen(args, struct_builders, blocks, sub): ...@@ -276,7 +276,18 @@ def struct_gen(args, struct_builders, blocks, sub):
%(storage_decl)s %(storage_decl)s
%(struct_decl)s %(struct_decl)s
%(name)s() {} %(name)s() {
// This is only somewhat safe because we:
// 1) Are not a virtual class
// 2) Do not use any virtual classes in the members
// 3) Deal with mostly POD and pointers
// If this changes, we would have to revise this, but for
// now I am tired of chasing segfaults because
// initialization code had an error and some pointer has
// a junk value.
memset(this, 0, sizeof(*this));
}
~%(name)s(void) { ~%(name)s(void) {
cleanup(); cleanup();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论