summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNei <ailin.nemui@gmail.com>2017-02-03 11:49:16 +0000
committerailin-nemui <ailin-nemui@users.noreply.github.com>2017-02-03 20:29:22 +0100
commit97b182089eec8cc158313c424b453dcaa39e05af (patch)
treeba5ebeb84d8239830741731565907dcb9d3493ba /src
parentca5e9bd623862bd9a640bf8799aafa53502b79f6 (diff)
downloadirssi-97b182089eec8cc158313c424b453dcaa39e05af.zip
Merge branch 'dub-the-wub' into 'master'
Prevent a memory leak during the processing of the SASL response. See merge request !8
Diffstat (limited to 'src')
-rw-r--r--src/irc/core/sasl.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c
index 1021bea4..635b7dfb 100644
--- a/src/irc/core/sasl.c
+++ b/src/irc/core/sasl.c
@@ -174,10 +174,16 @@ static gboolean sasl_reassemble_incoming(IRC_SERVER_REC *server, const char *fra
*decoded = g_string_new_len("", 0);
} else {
gsize dec_len;
- gchar *tmp;
-
- tmp = (gchar *) g_base64_decode(enc_req->str, &dec_len);
- *decoded = g_string_new_len(tmp, dec_len);
+ gint state = 0;
+ guint save = 0;
+
+ /* Since we're not going to use the enc_req GString anymore we
+ * can perform the decoding in place. */
+ dec_len = g_base64_decode_step(enc_req->str, enc_req->len,
+ (guchar *)enc_req->str,
+ &state, &save);
+ /* A copy of the data is made when the GString is created. */
+ *decoded = g_string_new_len(enc_req->str, dec_len);
}
g_string_free(enc_req, TRUE);