apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject svn commit: r910597 - /apr/apr/trunk/shmem/unix/shm.c
Date Tue, 16 Feb 2010 17:07:10 GMT
Author: jfclere
Date: Tue Feb 16 17:07:09 2010
New Revision: 910597

URL: http://svn.apache.org/viewvc?rev=910597&view=rev
Log:
Make sure we don't leak file descriptors.

Modified:
    apr/apr/trunk/shmem/unix/shm.c

Modified: apr/apr/trunk/shmem/unix/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/shmem/unix/shm.c?rev=910597&r1=910596&r2=910597&view=diff
==============================================================================
--- apr/apr/trunk/shmem/unix/shm.c (original)
+++ apr/apr/trunk/shmem/unix/shm.c Tue Feb 16 17:07:09 2010
@@ -314,26 +314,31 @@
          * exist before calling ftok(). */
         new_m->shmkey = ftok(filename, 1);
         if (new_m->shmkey == (key_t)-1) {
+            apr_file_close(file);
             return errno;
         }
 
         if ((new_m->shmid = shmget(new_m->shmkey, new_m->realsize,
                                    SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) {
+            apr_file_close(file);
             return errno;
         }
 
         if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) {
+            apr_file_close(file);
             return errno;
         }
         new_m->usable = new_m->base;
 
         if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) {
+            apr_file_close(file);
             return errno;
         }
         apr_uid_current(&uid, &gid, pool);
         shmbuf.shm_perm.uid = uid;
         shmbuf.shm_perm.gid = gid;
         if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) {
+            apr_file_close(file);
             return errno;
         }
 
@@ -341,6 +346,7 @@
         status = apr_file_write(file, (const void *)&reqsize,
                                 &nbytes);
         if (status != APR_SUCCESS) {
+            apr_file_close(file);
             return status;
         }
         status = apr_file_close(file);



Mime
View raw message