4 Commits

Author SHA1 Message Date
da7b32cbba fix: Resolve memory leak in verify_any and verify_last by destroying GTimer
The GTimer objects created in verify_any() and verify_last() functions
were never freed, causing memory leaks detected by Valgrind.

This fix adds g_timer_destroy(timer) calls after the while loops to
properly release the allocated timer resources.
2025-12-24 16:25:39 +03:00
6faee6177d Merge pull request 'fix: Resolve memory leak in stanza_parse by freeing parse state' (#2) from fix/memory-leak-stanza-parse into master
No functional changes to the parsing behavior
2025-12-24 12:38:15 +00:00
9a41c959ca fix: Resolve memory leak in stanza_parse by freeing parse state 2025-12-24 15:34:26 +03:00
00f47a1598 fix: Fix XMPP stream parsing and add stbbr_for_presence_to helper (#1)
This PR fixes critical issues with XMPP stream parsing and adds a new helper function for MUC testing.

## Changes

### 1. Fix XMPP stream parsing for multiple stanzas
The XML parser was not correctly handling multiple consecutive stanzas in the stream. Fixed depth tracking to properly detect stanza boundaries.

### 2. Fix XMPP stream parsing depth tracking
Added proper depth tracking for nested XML elements to correctly identify when a complete stanza has been received.

### 3. Remove debug logging that interfered with expect tests
Removed verbose debug output that was causing expect-based functional tests to fail due to unexpected output in the stream.

### 4. Add `stbbr_for_presence_to` for MUC join presence matching
New helper function that registers a canned response for presence stanzas based on the `to` attribute. This is essential for testing MUC (Multi-User Chat) join flows where the response must be triggered by presence to a specific room JID.

**API:**
```c
void stbbr_for_presence_to(const char *to, const char *response);

Reviewed-on: jabber.developer2/stabber#1
Co-authored-by: jabber.developer2 <jabber.developer2@jabber.space>
Co-committed-by: jabber.developer2 <jabber.developer2@jabber.space>
2025-12-15 08:45:38 +00:00
2 changed files with 5 additions and 1 deletions

View File

@@ -299,7 +299,9 @@ stanza_parse(char *stanza_text)
XML_Parse(parser, stanza_text, strlen(stanza_text), 0);
XML_ParserFree(parser);
return state->curr_stanza;
XMPPStanza *result = state->curr_stanza;
free(state);
return result;
}
static void

View File

@@ -63,6 +63,7 @@ verify_any(char *stanza_text, gboolean ign_timeout)
usleep(1000 * 50);
elapsed = g_timer_elapsed(timer, NULL);
}
g_timer_destroy(timer);
}
if (result) {
@@ -94,6 +95,7 @@ verify_last(char *stanza_text)
usleep(1000 * 50);
elapsed = g_timer_elapsed(timer, NULL);
}
g_timer_destroy(timer);
}
if (result) {