summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44d3a70)
raw | patch | inline | side by side (parent: 44d3a70)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 16:09:00 +0000 (18:09 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 17:19:03 +0000 (19:19 +0200) |
Else, we'd access free'd memory when trying to do so.
src/core/object.c | patch | blob | history | |
t/unit/core/object_test.c | patch | blob | history |
diff --git a/src/core/object.c b/src/core/object.c
index 9101918654379a1ff41491df64187d399468d186..c39faf4aed2c89f684a3e2c0c947b0eba7fe2d18 100644 (file)
--- a/src/core/object.c
+++ b/src/core/object.c
if (obj->ref_cnt > 0)
return;
+ /* we'd access free'd memory in case ref_cnt < 0 */
+ assert(! obj->ref_cnt);
+
if (obj->type.destroy)
obj->type.destroy(obj);
index dec6d41c73a3f989e97fcd85c79e4a950908ab79..73d7c86e1f1b21c18de0746ec250132df1001706 100644 (file)
"%d time%s; expected: 0", destroy_noop_called == 1 ? "" : "2",
destroy_noop_called);
- /* test_obj_create already checks the ref_cnt == 1 case */
- obj->ref_cnt = 0;
+ obj->ref_cnt = 1;
sdb_object_deref(obj);
fail_unless(init_noop_called == 1,
"after some sdb_object_{de,}ref(); object's init called %d times; "