Fixed BehaviourSanitizer warning in rdp parser
authorakallabeth <akallabeth@posteo.net>
Fri, 15 May 2020 14:55:58 +0000 (16:55 +0200)
committerakallabeth <akallabeth@posteo.net>
Mon, 18 May 2020 15:10:01 +0000 (17:10 +0200)
(cherry picked from commit 771332c04e2dbad964d0cb11a86ff561e792bc35)

client/common/file.c

index 7cac1ac..b9ded26 100644 (file)
@@ -203,6 +203,7 @@ struct rdp_file
        DWORD flags;
 };
 
+static void freerdp_client_file_string_check_free(LPSTR str);
 /*
  * Set an integer in a rdpFile
  *
@@ -841,15 +842,16 @@ BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_
        return status;
 }
 
-#define FILE_POPULATE_STRING(_target, _setting) \
-       do                                          \
-       {                                           \
-               if (_setting)                           \
-               {                                       \
-                       _target = _strdup(_setting);        \
-                       if (!_target)                       \
-                               return FALSE;                   \
-               }                                       \
+#define FILE_POPULATE_STRING(_target, _setting)             \
+       do                                                      \
+       {                                                       \
+               if (_setting)                                       \
+               {                                                   \
+                       freerdp_client_file_string_check_free(_target); \
+                       _target = _strdup(_setting);                    \
+                       if (!_target)                                   \
+                               return FALSE;                               \
+               }                                                   \
        } while (0)
 
 BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSettings* settings)