Hi all!

When looking at lxde code I noticed that in xml-purge tool is little
inconsistency - the tool does not close file that had opened (fd and
fo). I think I fixed it. Patch attached.

(should I make diff of each directory separately? Are there any doc on
how to prepare patch to the list?)


-- 
My public key can be found at https://keyserver2.pgp.com
Index: devtools/xml-purge/xml-purge.c
===================================================================
--- devtools/xml-purge/xml-purge.c      (revision 2199)
+++ devtools/xml-purge/xml-purge.c      (working copy)
@@ -22,13 +22,17 @@
                return;
 
        if( fstat( fd, &statbuf) == -1 )
+       {
+               close( fd );
                return;
+       }
 
        if( buf = (char*)malloc( statbuf.st_size + 1 ) )
        {
                if( read( fd, buf, statbuf.st_size) == -1 )
                {
                        free( buf );
+                       close( fd );
                        return;
                }
                buf[ statbuf.st_size ] = '\0';
@@ -104,9 +108,9 @@
                }
        }
        
-       fclose( fo );
-
 error:
+       if( fo )
+               fclose( fo );
        free( buf );
 }
 
Index: lxpanel/src/xml-purge.c
===================================================================
--- lxpanel/src/xml-purge.c     (revision 2199)
+++ lxpanel/src/xml-purge.c     (working copy)
@@ -22,13 +22,17 @@
                return;
 
        if( fstat( fd, &statbuf) == -1 )
+       {
+               close( fd );
                return;
+       }
 
        if( (buf = (char*)malloc( statbuf.st_size + 1 )) )
        {
                if( read( fd, buf, statbuf.st_size) == -1 )
                {
                        free( buf );
+                       close( fd );
                        return;
                }
                buf[ statbuf.st_size ] = '\0';
@@ -104,9 +108,9 @@
                }
        }
        
-       fclose( fo );
-
 error:
+       if( fo )
+               fclose( fo );
        free( buf );
 }
 
Index: lxinput/src/xml-purge.c
===================================================================
--- lxinput/src/xml-purge.c     (revision 2199)
+++ lxinput/src/xml-purge.c     (working copy)
@@ -22,13 +22,17 @@
                return;
 
        if( fstat( fd, &statbuf) == -1 )
+       {
+               close( fd );
                return;
+       }
 
        if( buf = (char*)malloc( statbuf.st_size + 1 ) )
        {
                if( read( fd, buf, statbuf.st_size) == -1 )
                {
                        free( buf );
+                       close( fd );
                        return;
                }
                buf[ statbuf.st_size ] = '\0';
@@ -104,9 +108,9 @@
                }
        }
        
-       fclose( fo );
-
 error:
+       if( fo )
+               fclose( fo );
        free( buf );
 }
 
Index: lxsession-edit/src/xml-purge.c
===================================================================
--- lxsession-edit/src/xml-purge.c      (revision 2199)
+++ lxsession-edit/src/xml-purge.c      (working copy)
@@ -22,13 +22,17 @@
                return;
 
        if( fstat( fd, &statbuf) == -1 )
+       {
+               close( fd );
                return;
+       }
 
        if( buf = (char*)malloc( statbuf.st_size + 1 ) )
        {
                if( read( fd, buf, statbuf.st_size) == -1 )
                {
                        free( buf );
+                       close( fd );
                        return;
                }
                buf[ statbuf.st_size ] = '\0';
@@ -104,9 +108,9 @@
                }
        }
        
-       fclose( fo );
-
 error:
+       if( fo )
+               fclose( fo );
        free( buf );
 }
 
Index: gpicview/src/xml-purge.c
===================================================================
--- gpicview/src/xml-purge.c    (revision 2199)
+++ gpicview/src/xml-purge.c    (working copy)
@@ -22,13 +22,17 @@
                return;
 
        if( fstat( fd, &statbuf) == -1 )
+       {
+               close( fd );
                return;
+       }
 
        if( buf = (char*)malloc( statbuf.st_size + 1 ) )
        {
                if( read( fd, buf, statbuf.st_size) == -1 )
                {
                        free( buf );
+                       close( fd );
                        return;
                }
                buf[ statbuf.st_size ] = '\0';
@@ -104,9 +108,9 @@
                }
        }
        
-       fclose( fo );
-
 error:
+       if( fo )
+               fclose( fo );
        free( buf );
 }
 
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Lxde-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxde-list

Reply via email to