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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These leaks are detected for instance by address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]