1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Free key on error in omemo_start_device_session_handle_bundle()

Fix:
```
==20561== 32 bytes in 1 blocks are definitely lost in loss record 1,467
of 3,678
==20561==    at 0x483677F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20561==    by 0x4B16C9: omemo_start_device_session_handle_bundle
(omemo.c:167)
==20561==    by 0x43405E: _iq_handler (iq.c:214)
==20561==    by 0x5AF118E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x5AEDBDA: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x5AFA43E: ??? (in /usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x6818AA4: ??? (in /usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x681A3AB: ??? (in /usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x681D7EB: XML_ParseBuffer (in
/usr/lib64/libexpat.so.1.6.8)
==20561==    by 0x5AF0A63: xmpp_run_once (in
/usr/lib64/libmesode.so.0.0.0)
==20561==    by 0x432E5D: connection_check_events (connection.c:104)
==20561==    by 0x4323B3: session_process_events (session.c:255)
==20561==    by 0x42C097: prof_run (profanity.c:128)
==20561==    by 0x4B260D: main (main.c:172)
```
This commit is contained in:
Michael Vetter 2019-07-04 11:55:53 +02:00
parent e3443f5c9a
commit 482138feff

View File

@ -168,13 +168,18 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *cons
const char *prekey_id_text = xmpp_stanza_get_attribute(prekey, "preKeyId");
if (!prekey_id_text) {
omemo_key_free(key);
goto out;
}
key->id = strtoul(prekey_id_text, NULL, 10);
xmpp_stanza_t *prekey_text = xmpp_stanza_get_children(prekey);
if (!prekey_text) {
omemo_key_free(key);
goto out;
}
char *prekey_b64 = xmpp_stanza_get_text(prekey_text);
key->data = g_base64_decode(prekey_b64, &key->length);
free(prekey_b64);