Martin Ettl <ettl DOT martin AT gmx DOT de>: Fix various resource and memory leaks
authorGregor Schneider <grschneider@gmail.com>
Wed, 2 Dec 2009 18:28:52 +0000 (18:28 +0000)
committerGregor Schneider <grschneider@gmail.com>
Wed, 2 Dec 2009 18:28:52 +0000 (18:28 +0000)
See issue #4974 for more details.

svn path=/trunk/; revision=44364

reactos/base/applications/network/telnet/src/tnetwork.h
reactos/base/applications/tsclient/rdesktop/printercache.c
reactos/base/applications/tsclient/rdesktop/rdesktop.c
reactos/base/applications/tsclient/rdesktop/uiports/qtwin.cpp

index 64dfb11..bcc78c7 100644 (file)
@@ -24,7 +24,7 @@ public:
        TNetwork(SOCKET s = 0): socket(s), local_echo(1), line_mode(1),
                net_type(TN_NETSOCKET), naws_func((Naws_func_t)NULL),
                local_address((char *)NULL) {}
-       ~TNetwork() {if(local_address) delete local_address;}
+       ~TNetwork() {if(local_address) delete[] local_address;}
 
        void SetSocket(SOCKET s);
        SOCKET GetSocket() {return socket;}
index 38b38bb..c2d39bf 100644 (file)
@@ -180,6 +180,7 @@ printercache_load_blob(char *printer_name, uint8 ** data)
        if (fstat(fd, &st))
        {
                xfree(path);
+               close(fd);
                return 0;
        }
 
index 425ce05..37e5f38 100644 (file)
@@ -1405,7 +1405,10 @@ load_licence(RDPCLIENT * This, unsigned char **data)
                return -1;
 
        if (fstat(fd, &st))
+       {
+               close(fd);
                return -1;
+       }
 
        *data = (uint8 *) xmalloc(st.st_size);
        length = read(fd, *data, st.st_size);
index 718ba2d..a23727e 100644 (file)
@@ -1475,6 +1475,8 @@ int load_licence(uint8 ** data)
   }
   if (fstat(fd, &st))
   {
+    close(fd);
+    xfree(path);
     return -1;
   }
   *data = (uint8 *) xmalloc(st.st_size);