diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-07-30 13:49:29 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-08 22:42:52 +0200 |
commit | 4fd8b3538c7351ac39ea81533727a99ff3e4abb2 (patch) | |
tree | a055c03e1c1981dcb6b182bc57159857296753b6 /include/sqfs | |
parent | d17046773702aad9cb3269a23ecd35f5a4a552ff (diff) |
Fix reference count of copied objects
Always set the reference count to 1 after creating a copy
of an object.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs')
-rw-r--r-- | include/sqfs/predef.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h index 9e32b42..fbc6519 100644 --- a/include/sqfs/predef.h +++ b/include/sqfs/predef.h @@ -186,9 +186,13 @@ static SQFS_INLINE void *sqfs_drop(void *obj) */ static SQFS_INLINE void *sqfs_copy(const void *obj) { - if (((const sqfs_object_t *)obj)->copy != NULL) { - return ((const sqfs_object_t *)obj)-> - copy((const sqfs_object_t *)obj); + const sqfs_object_t *orig = (const sqfs_object_t *)obj; + + if (orig->copy != NULL) { + sqfs_object_t *copy = orig->copy(orig); + if (copy != NULL) + copy->refcount = 1; + return copy; } return NULL; |