[Spice-devel] [PATCH spice-server 2/3] test-gst: Remove options parsing leaks

Frediano Ziglio fziglio at redhat.com
Mon Sep 11 08:12:17 UTC 2017


These leaks are detected for instance by address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/tests/test-gst.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index 40f738d78..224a891b1 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -314,11 +314,11 @@ static const EncoderInfo encoder_infos[] = {
 int main(int argc, char *argv[])
 {
     gchar *input_pipeline_desc = NULL;
-    const gchar *image_format = "32BIT";
-    const gchar *encoder_name = "mjpeg";
+    gchar *image_format = NULL;
+    gchar *encoder_name = NULL;
     gchar *file_report_name = NULL;
     gboolean use_hw_encoder = FALSE; // TODO use
-    const gchar *clipping = "(0,0)x(100%,100%)";
+    gchar *clipping = NULL;
 
     // - input pipeline
     // - top/down
@@ -368,19 +368,19 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-    const EncoderInfo *encoder = get_encoder_info(encoder_name);
+    const EncoderInfo *encoder = get_encoder_info(encoder_name ? encoder_name : "mjpeg");
     if (!encoder) {
         g_printerr("Encoder name unsupported: %s\n", encoder_name);
         exit(1);
     }
 
-    bitmap_format = get_bitmap_format(image_format);
+    bitmap_format = get_bitmap_format(image_format ? image_format : "32BIT");
     if (bitmap_format == SPICE_BITMAP_FMT_INVALID) {
         g_printerr("Invalid image format: %s\n", image_format);
         exit(1);
     }
 
-    parse_clipping(clipping);
+    parse_clipping(clipping ? clipping : "(0,0)x(100%,100%)");
 
     if (minimum_psnr < 0) {
         g_printerr("Invalid PSNR specified %f\n", minimum_psnr);
@@ -432,6 +432,12 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
+    g_free(encoder_name);
+    g_free(image_format);
+    g_free(input_pipeline_desc);
+    g_free(clipping);
+    g_option_context_free(context);
+
     return 0;
 }
 
-- 
2.13.5



More information about the Spice-devel mailing list