core/info: Fix leak found by covscan
authorOndrej Holy <oholy@redhat.com>
Fri, 17 Aug 2018 14:10:26 +0000 (16:10 +0200)
committerOndrej Holy <oholy@redhat.com>
Wed, 22 Aug 2018 12:34:02 +0000 (14:34 +0200)
leaked_storage: Variable "wString" going out of scope leaks the storage it points to.

libfreerdp/core/info.c

index 006585b..fa97f4b 100644 (file)
@@ -1218,7 +1218,10 @@ static BOOL rdp_write_logon_info_v1(wStream* s, logon_info* info)
        len *= 2;
 
        if (len > 52)
+       {
+               free(wString);
                return FALSE;
+       }
 
        Stream_Write_UINT32(s, len);
        Stream_Write(s, wString, len);
@@ -1233,7 +1236,10 @@ static BOOL rdp_write_logon_info_v1(wStream* s, logon_info* info)
        len *= 2;
 
        if (len > 512)
+       {
+               free(wString);
                return FALSE;
+       }
 
        Stream_Write_UINT32(s, len);
        Stream_Write(s, wString, len);