[Spice-devel] [PATCH spice-server 06/16] red-stream: Avoid useless copy of mechlist
Frediano Ziglio
fziglio at redhat.com
Thu Dec 14 10:07:38 UTC 2017
The list will persist will the SASL connection is not disposed
(or another sasl_listmech called).
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red-stream.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/server/red-stream.c b/server/red-stream.c
index b5eb7cd31..321612bac 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -68,7 +68,7 @@ typedef struct RedSASL {
SpiceBuffer inbuffer;
- char *mechlist;
+ const char *mechlist;
char *mechname;
/* temporary data during authentication */
@@ -354,9 +354,7 @@ void red_stream_free(RedStream *s)
s->priv->sasl.len = 0;
s->priv->sasl.encodedLength = s->priv->sasl.encodedOffset = 0;
s->priv->sasl.encoded = NULL;
- g_free(s->priv->sasl.mechlist);
g_free(s->priv->sasl.mechname);
- s->priv->sasl.mechlist = NULL;
g_free(s->priv->sasl.data);
sasl_dispose(&s->priv->sasl.conn);
s->priv->sasl.conn = NULL;
@@ -1110,7 +1108,7 @@ bool red_sasl_start_auth(RedStream *stream, AsyncReadDone read_cb, void *opaque)
spice_debug("Available mechanisms for client: '%s'", mechlist);
- sasl->mechlist = g_strdup(mechlist);
+ sasl->mechlist = mechlist;
mechlistlen = strlen(mechlist);
if (!red_stream_write_all(stream, &mechlistlen, sizeof(uint32_t))
@@ -1126,6 +1124,7 @@ bool red_sasl_start_auth(RedStream *stream, AsyncReadDone read_cb, void *opaque)
return true;
error_dispose:
+ sasl->mechlist = NULL;
sasl_dispose(&sasl->conn);
sasl->conn = NULL;
error:
--
2.14.3
More information about the Spice-devel
mailing list