client/common: Fix leak found by covscan
authorOndrej Holy <oholy@redhat.com>
Fri, 17 Aug 2018 12:40:12 +0000 (14:40 +0200)
committerOndrej Holy <oholy@redhat.com>
Wed, 22 Aug 2018 11:35:43 +0000 (13:35 +0200)
leaked_storage: Variable "file" going out of scope leaks the storage it points to.

client/common/client.c

index 2c8bbbb..ef5db97 100644 (file)
@@ -306,6 +306,7 @@ int freerdp_client_settings_parse_assistance_file(rdpSettings* settings,
         const char* filename)
 {
        int status;
+       int ret = -1;
        rdpAssistanceFile* file;
        file = freerdp_assistance_file_new();
 
@@ -315,15 +316,17 @@ int freerdp_client_settings_parse_assistance_file(rdpSettings* settings,
        status = freerdp_assistance_parse_file(file, filename);
 
        if (status < 0)
-               return -1;
+               goto out;
 
        status = freerdp_client_populate_settings_from_assistance_file(file, settings);
 
        if (status < 0)
-               return -1;
+               goto out;
 
+       ret = 0;
+out:
        freerdp_assistance_file_free(file);
-       return 0;
+       return ret;
 }
 
 /** Callback set in the rdp_freerdp structure, and used to get the user's password,