Skip to content

Commit

Permalink
Fix 'cowl_release_all' not releasing all operands if one is NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Sep 4, 2024
1 parent 709e106 commit 74666a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/cowl_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ COWL_RETAINED
CowlAnyEntity *cowl_entity_from_string_impl(CowlObjectType type, UString string);

COWL_API
void cowl_release_all_impl(CowlAny **objects);
void cowl_release_all_impl(CowlAny **objects, size_t count);

COWL_API
CowlAny **cowl_get_fields(CowlAny *object, unsigned *count);
Expand Down
5 changes: 3 additions & 2 deletions include/cowl_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ bool cowl_iterate_primitives(CowlAny *object, CowlPrimitiveFlags flags, CowlIter
*/
#define cowl_release_all(...) \
do { \
CowlAny *p_cowl_release_all_##__LINE__[] = { __VA_ARGS__, NULL }; \
cowl_release_all_impl(p_cowl_release_all_##__LINE__); \
CowlAny *p_cowl_release_all_##__LINE__[] = { __VA_ARGS__ }; \
cowl_release_all_impl(p_cowl_release_all_##__LINE__, \
ulib_array_count(p_cowl_release_all_##__LINE__)); \
} while (0)

/// @}
Expand Down
6 changes: 3 additions & 3 deletions src/cowl_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ CowlAny *cowl_get_impl_uint(CowlObjectType type, CowlAny *fields[], ulib_uint va
return obj;
}

void cowl_release_all_impl(CowlAny **objects) {
while (*objects) {
cowl_release(*(objects++));
void cowl_release_all_impl(CowlAny **objects, size_t count) {
while (count--) {
cowl_release(objects[count]);
}
}

Expand Down

0 comments on commit 74666a2

Please sign in to comment.