upstream: fix: fix api_get_current_occupants() memory problems (1ec536d34)

This commit is contained in:
2026-03-31 19:52:25 +03:00
parent 034b789f1c
commit 56488dd2f9

View File

@@ -261,6 +261,11 @@ api_get_current_occupants(void)
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
GList* occupants_list = muc_roster(mucwin->roomjid);
char** result = malloc((g_list_length(occupants_list) + 1) * sizeof(char*));
if (result == NULL) {
g_list_free(occupants_list);
return NULL;
}
GList* curr = occupants_list;
int i = 0;
while (curr) {
@@ -269,6 +274,9 @@ api_get_current_occupants(void)
curr = g_list_next(curr);
}
result[i] = NULL;
g_list_free(occupants_list);
return result;
} else {
return NULL;