Commit 54e84dff authored by David Goulet's avatar David Goulet Committed by Ian Goldberg

Fix: possible memory leak in otrl_message_sending

Make sure we free the old messagep value if the fragment_and_send call
successfully sets it to a new value.

(Repairs a problem introduced in c87b3fe6)

Fixes #25Reported-by: MartinMilata's avatarb42 <b42@srck.net>
Signed-off-by: 's avatarDavid Goulet <dgoulet@ev0ke.net>
Signed-off-by: 's avatarIan Goldberg <iang@cs.uwaterloo.ca>
parent 6e5c3d9e
......@@ -441,8 +441,15 @@ fragment:
/* Fragment and send according to policy */
if (!err && messagep && *messagep) {
if (context) {
char *rmessagep = NULL;
err = fragment_and_send(ops, opdata, context, *messagep,
fragPolicy, messagep);
fragPolicy, &rmessagep);
if (rmessagep) {
/* Free the current message pointer and return back the
* returned fragmented one. */
free(*messagep);
*messagep = rmessagep;
}
}
}
return err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment