[Spice-devel] [PATCH spice-server] reds: Fix use-after-free

Frediano Ziglio fziglio at redhat.com
Wed Jul 17 10:41:33 UTC 2019


video_codecs can be freed so use it before.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/reds.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 817fdd423..78bbe5a0f 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3851,6 +3851,10 @@ static int reds_set_video_codecs_from_string(RedsState *reds, const char *codecs
         codecs = c;
     }
 
+    if (installed) {
+        *installed = video_codecs->len;
+    }
+
     if (video_codecs->len == 0) {
         spice_warning("Failed to set video codecs, input string: '%s'", codecs);
         g_array_unref(video_codecs);
@@ -3860,10 +3864,6 @@ static int reds_set_video_codecs_from_string(RedsState *reds, const char *codecs
 
     g_free(codecs_copy);
 
-    if (installed) {
-        *installed = video_codecs->len;
-    }
-
     return invalid_codecs;
 }
 
-- 
2.20.1



More information about the Spice-devel mailing list